From 71f982d209987bd4d39e157d6500b9ae0aded7be Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Fri, 5 Aug 2022 09:10:22 +0000 Subject: [PATCH] CodeGen from PR 20127 in Azure/azure-rest-api-specs Merge 90942d2db08ab831ccf19956193d221118e216dd into 63f4e39c20223c20941614e776d33e699c3e2777 --- .../CHANGELOG.md | 5 + .../azure-mgmt-managedapplication/LICENSE | 21 + .../azure-mgmt-managedapplication/MANIFEST.in | 7 + .../azure-mgmt-managedapplication/README.md | 30 + .../azure-mgmt-managedapplication/_meta.json | 11 + .../azure/__init__.py | 1 + .../azure/mgmt/__init__.py | 1 + .../azure/mgmt/managedapplication/__init__.py | 16 + .../managedapplication/_application_client.py | 253 ++ .../mgmt/managedapplication/_configuration.py | 71 + .../managedapplication/_operations_mixin.py | 67 + .../azure/mgmt/managedapplication/_version.py | 8 + .../mgmt/managedapplication/aio/__init__.py | 10 + .../aio/_application_client.py | 252 ++ .../managedapplication/aio/_configuration.py | 67 + .../aio/_operations_mixin.py | 62 + .../azure/mgmt/managedapplication/models.py | 7 + .../azure/mgmt/managedapplication/py.typed | 1 + .../v2017_09_01/__init__.py | 23 + .../v2017_09_01/_application_client.py | 106 + .../v2017_09_01/_configuration.py | 73 + .../v2017_09_01/_metadata.json | 122 + .../managedapplication/v2017_09_01/_patch.py | 19 + .../managedapplication/v2017_09_01/_vendor.py | 45 + .../v2017_09_01/_version.py | 9 + .../v2017_09_01/aio/__init__.py | 20 + .../v2017_09_01/aio/_application_client.py | 103 + .../v2017_09_01/aio/_configuration.py | 72 + .../v2017_09_01/aio/_patch.py | 19 + .../v2017_09_01/aio/_vendor.py | 27 + .../v2017_09_01/aio/operations/__init__.py | 22 + .../_application_client_operations.py | 105 + .../_application_definitions_operations.py | 487 +++ .../operations/_applications_operations.py | 1149 +++++++ .../v2017_09_01/aio/operations/_patch.py | 19 + .../v2017_09_01/models/__init__.py | 69 + .../models/_application_client_enums.py | 57 + .../v2017_09_01/models/_models_py3.py | 1175 +++++++ .../v2017_09_01/models/_patch.py | 19 + .../v2017_09_01/operations/__init__.py | 22 + .../_application_client_operations.py | 134 + .../_application_definitions_operations.py | 720 +++++ .../operations/_applications_operations.py | 1530 ++++++++++ .../v2017_09_01/operations/_patch.py | 19 + .../managedapplication/v2017_09_01/py.typed | 1 + .../v2017_12_01/__init__.py | 23 + .../v2017_12_01/_application_client.py | 106 + .../v2017_12_01/_configuration.py | 73 + .../v2017_12_01/_metadata.json | 122 + .../managedapplication/v2017_12_01/_patch.py | 19 + .../managedapplication/v2017_12_01/_vendor.py | 45 + .../v2017_12_01/_version.py | 9 + .../v2017_12_01/aio/__init__.py | 20 + .../v2017_12_01/aio/_application_client.py | 103 + .../v2017_12_01/aio/_configuration.py | 72 + .../v2017_12_01/aio/_patch.py | 19 + .../v2017_12_01/aio/_vendor.py | 27 + .../v2017_12_01/aio/operations/__init__.py | 22 + .../_application_client_operations.py | 105 + .../_application_definitions_operations.py | 487 +++ .../operations/_applications_operations.py | 1149 +++++++ .../v2017_12_01/aio/operations/_patch.py | 19 + .../v2017_12_01/models/__init__.py | 69 + .../models/_application_client_enums.py | 57 + .../v2017_12_01/models/_models_py3.py | 1175 +++++++ .../v2017_12_01/models/_patch.py | 19 + .../v2017_12_01/operations/__init__.py | 22 + .../_application_client_operations.py | 134 + .../_application_definitions_operations.py | 720 +++++ .../operations/_applications_operations.py | 1530 ++++++++++ .../v2017_12_01/operations/_patch.py | 19 + .../managedapplication/v2017_12_01/py.typed | 1 + .../v2018_02_01/__init__.py | 23 + .../v2018_02_01/_application_client.py | 106 + .../v2018_02_01/_configuration.py | 73 + .../v2018_02_01/_metadata.json | 122 + .../managedapplication/v2018_02_01/_patch.py | 19 + .../managedapplication/v2018_02_01/_vendor.py | 45 + .../v2018_02_01/_version.py | 9 + .../v2018_02_01/aio/__init__.py | 20 + .../v2018_02_01/aio/_application_client.py | 103 + .../v2018_02_01/aio/_configuration.py | 72 + .../v2018_02_01/aio/_patch.py | 19 + .../v2018_02_01/aio/_vendor.py | 27 + .../v2018_02_01/aio/operations/__init__.py | 22 + .../_application_client_operations.py | 105 + .../_application_definitions_operations.py | 761 +++++ .../operations/_applications_operations.py | 1269 ++++++++ .../v2018_02_01/aio/operations/_patch.py | 19 + .../v2018_02_01/models/__init__.py | 99 + .../models/_application_client_enums.py | 102 + .../v2018_02_01/models/_models_py3.py | 1690 +++++++++++ .../v2018_02_01/models/_patch.py | 19 + .../v2018_02_01/operations/__init__.py | 22 + .../_application_client_operations.py | 134 + .../_application_definitions_operations.py | 1158 +++++++ .../operations/_applications_operations.py | 1687 +++++++++++ .../v2018_02_01/operations/_patch.py | 19 + .../managedapplication/v2018_02_01/py.typed | 1 + .../v2018_03_01/__init__.py | 23 + .../v2018_03_01/_application_client.py | 112 + .../v2018_03_01/_configuration.py | 73 + .../v2018_03_01/_metadata.json | 123 + .../managedapplication/v2018_03_01/_patch.py | 19 + .../managedapplication/v2018_03_01/_vendor.py | 45 + .../v2018_03_01/_version.py | 9 + .../v2018_03_01/aio/__init__.py | 20 + .../v2018_03_01/aio/_application_client.py | 109 + .../v2018_03_01/aio/_configuration.py | 72 + .../v2018_03_01/aio/_patch.py | 19 + .../v2018_03_01/aio/_vendor.py | 27 + .../v2018_03_01/aio/operations/__init__.py | 24 + .../_application_client_operations.py | 105 + .../_application_definitions_operations.py | 761 +++++ .../operations/_applications_operations.py | 1481 +++++++++ .../operations/_jit_requests_operations.py | 502 +++ .../v2018_03_01/aio/operations/_patch.py | 19 + .../v2018_03_01/models/__init__.py | 135 + .../models/_application_client_enums.py | 157 + .../v2018_03_01/models/_models_py3.py | 2298 ++++++++++++++ .../v2018_03_01/models/_patch.py | 19 + .../v2018_03_01/operations/__init__.py | 24 + .../_application_client_operations.py | 134 + .../_application_definitions_operations.py | 1158 +++++++ .../operations/_applications_operations.py | 1989 ++++++++++++ .../operations/_jit_requests_operations.py | 736 +++++ .../v2018_03_01/operations/_patch.py | 19 + .../managedapplication/v2018_03_01/py.typed | 1 + .../v2018_06_01/__init__.py | 23 + .../v2018_06_01/_application_client.py | 112 + .../v2018_06_01/_configuration.py | 73 + .../v2018_06_01/_metadata.json | 123 + .../managedapplication/v2018_06_01/_patch.py | 19 + .../managedapplication/v2018_06_01/_vendor.py | 45 + .../v2018_06_01/_version.py | 9 + .../v2018_06_01/aio/__init__.py | 20 + .../v2018_06_01/aio/_application_client.py | 109 + .../v2018_06_01/aio/_configuration.py | 72 + .../v2018_06_01/aio/_patch.py | 19 + .../v2018_06_01/aio/_vendor.py | 27 + .../v2018_06_01/aio/operations/__init__.py | 24 + .../_application_client_operations.py | 105 + .../_application_definitions_operations.py | 761 +++++ .../operations/_applications_operations.py | 1481 +++++++++ .../operations/_jit_requests_operations.py | 502 +++ .../v2018_06_01/aio/operations/_patch.py | 19 + .../v2018_06_01/models/__init__.py | 137 + .../models/_application_client_enums.py | 141 + .../v2018_06_01/models/_models_py3.py | 2394 +++++++++++++++ .../v2018_06_01/models/_patch.py | 19 + .../v2018_06_01/operations/__init__.py | 24 + .../_application_client_operations.py | 134 + .../_application_definitions_operations.py | 1158 +++++++ .../operations/_applications_operations.py | 1989 ++++++++++++ .../operations/_jit_requests_operations.py | 736 +++++ .../v2018_06_01/operations/_patch.py | 19 + .../managedapplication/v2018_06_01/py.typed | 1 + .../v2018_09_01_preview/__init__.py | 23 + .../_application_client.py | 112 + .../v2018_09_01_preview/_configuration.py | 73 + .../v2018_09_01_preview/_metadata.json | 123 + .../v2018_09_01_preview/_patch.py | 19 + .../v2018_09_01_preview/_vendor.py | 45 + .../v2018_09_01_preview/_version.py | 9 + .../v2018_09_01_preview/aio/__init__.py | 20 + .../aio/_application_client.py | 109 + .../v2018_09_01_preview/aio/_configuration.py | 72 + .../v2018_09_01_preview/aio/_patch.py | 19 + .../v2018_09_01_preview/aio/_vendor.py | 27 + .../aio/operations/__init__.py | 24 + .../_application_client_operations.py | 105 + .../_application_definitions_operations.py | 763 +++++ .../operations/_applications_operations.py | 1484 +++++++++ .../operations/_jit_requests_operations.py | 505 +++ .../aio/operations/_patch.py | 19 + .../v2018_09_01_preview/models/__init__.py | 131 + .../models/_application_client_enums.py | 141 + .../v2018_09_01_preview/models/_models_py3.py | 2311 ++++++++++++++ .../v2018_09_01_preview/models/_patch.py | 19 + .../operations/__init__.py | 24 + .../_application_client_operations.py | 134 + .../_application_definitions_operations.py | 1160 +++++++ .../operations/_applications_operations.py | 1992 ++++++++++++ .../operations/_jit_requests_operations.py | 739 +++++ .../v2018_09_01_preview/operations/_patch.py | 19 + .../v2018_09_01_preview/py.typed | 1 + .../v2019_07_01/__init__.py | 23 + .../v2019_07_01/_application_client.py | 112 + .../v2019_07_01/_configuration.py | 73 + .../v2019_07_01/_metadata.json | 123 + .../managedapplication/v2019_07_01/_patch.py | 19 + .../managedapplication/v2019_07_01/_vendor.py | 45 + .../v2019_07_01/_version.py | 9 + .../v2019_07_01/aio/__init__.py | 20 + .../v2019_07_01/aio/_application_client.py | 109 + .../v2019_07_01/aio/_configuration.py | 72 + .../v2019_07_01/aio/_patch.py | 19 + .../v2019_07_01/aio/_vendor.py | 27 + .../v2019_07_01/aio/operations/__init__.py | 24 + .../_application_client_operations.py | 105 + .../_application_definitions_operations.py | 761 +++++ .../operations/_applications_operations.py | 1545 ++++++++++ .../operations/_jit_requests_operations.py | 502 +++ .../v2019_07_01/aio/operations/_patch.py | 19 + .../v2019_07_01/models/__init__.py | 147 + .../models/_application_client_enums.py | 157 + .../v2019_07_01/models/_models_py3.py | 2528 +++++++++++++++ .../v2019_07_01/models/_patch.py | 19 + .../v2019_07_01/operations/__init__.py | 24 + .../_application_client_operations.py | 134 + .../_application_definitions_operations.py | 1158 +++++++ .../operations/_applications_operations.py | 2090 +++++++++++++ .../operations/_jit_requests_operations.py | 736 +++++ .../v2019_07_01/operations/_patch.py | 19 + .../managedapplication/v2019_07_01/py.typed | 1 + .../v2020_08_21_preview/__init__.py | 23 + .../_application_client.py | 112 + .../v2020_08_21_preview/_configuration.py | 73 + .../v2020_08_21_preview/_metadata.json | 123 + .../v2020_08_21_preview/_patch.py | 19 + .../v2020_08_21_preview/_vendor.py | 45 + .../v2020_08_21_preview/_version.py | 9 + .../v2020_08_21_preview/aio/__init__.py | 20 + .../aio/_application_client.py | 109 + .../v2020_08_21_preview/aio/_configuration.py | 72 + .../v2020_08_21_preview/aio/_patch.py | 19 + .../v2020_08_21_preview/aio/_vendor.py | 27 + .../aio/operations/__init__.py | 24 + .../_application_client_operations.py | 105 + .../_application_definitions_operations.py | 763 +++++ .../operations/_applications_operations.py | 1480 +++++++++ .../operations/_jit_requests_operations.py | 505 +++ .../aio/operations/_patch.py | 19 + .../v2020_08_21_preview/models/__init__.py | 149 + .../models/_application_client_enums.py | 157 + .../v2020_08_21_preview/models/_models_py3.py | 2606 ++++++++++++++++ .../v2020_08_21_preview/models/_patch.py | 19 + .../operations/__init__.py | 24 + .../_application_client_operations.py | 134 + .../_application_definitions_operations.py | 1160 +++++++ .../operations/_applications_operations.py | 2025 +++++++++++++ .../operations/_jit_requests_operations.py | 739 +++++ .../v2020_08_21_preview/operations/_patch.py | 19 + .../v2020_08_21_preview/py.typed | 1 + .../v2021_02_01_preview/__init__.py | 23 + .../_application_client.py | 112 + .../v2021_02_01_preview/_configuration.py | 73 + .../v2021_02_01_preview/_metadata.json | 123 + .../v2021_02_01_preview/_patch.py | 19 + .../v2021_02_01_preview/_vendor.py | 45 + .../v2021_02_01_preview/_version.py | 9 + .../v2021_02_01_preview/aio/__init__.py | 20 + .../aio/_application_client.py | 109 + .../v2021_02_01_preview/aio/_configuration.py | 72 + .../v2021_02_01_preview/aio/_patch.py | 19 + .../v2021_02_01_preview/aio/_vendor.py | 27 + .../aio/operations/__init__.py | 24 + .../_application_client_operations.py | 105 + .../_application_definitions_operations.py | 763 +++++ .../operations/_applications_operations.py | 1548 ++++++++++ .../operations/_jit_requests_operations.py | 505 +++ .../aio/operations/_patch.py | 19 + .../v2021_02_01_preview/models/__init__.py | 153 + .../models/_application_client_enums.py | 166 + .../v2021_02_01_preview/models/_models_py3.py | 2699 +++++++++++++++++ .../v2021_02_01_preview/models/_patch.py | 19 + .../operations/__init__.py | 24 + .../_application_client_operations.py | 134 + .../_application_definitions_operations.py | 1160 +++++++ .../operations/_applications_operations.py | 2093 +++++++++++++ .../operations/_jit_requests_operations.py | 739 +++++ .../v2021_02_01_preview/operations/_patch.py | 19 + .../v2021_02_01_preview/py.typed | 1 + .../v2021_07_01/__init__.py | 23 + .../v2021_07_01/_application_client.py | 112 + .../v2021_07_01/_configuration.py | 73 + .../v2021_07_01/_metadata.json | 123 + .../managedapplication/v2021_07_01/_patch.py | 19 + .../managedapplication/v2021_07_01/_vendor.py | 45 + .../v2021_07_01/_version.py | 9 + .../v2021_07_01/aio/__init__.py | 20 + .../v2021_07_01/aio/_application_client.py | 109 + .../v2021_07_01/aio/_configuration.py | 72 + .../v2021_07_01/aio/_patch.py | 19 + .../v2021_07_01/aio/_vendor.py | 27 + .../v2021_07_01/aio/operations/__init__.py | 24 + .../_application_client_operations.py | 105 + .../_application_definitions_operations.py | 761 +++++ .../operations/_applications_operations.py | 1545 ++++++++++ .../operations/_jit_requests_operations.py | 502 +++ .../v2021_07_01/aio/operations/_patch.py | 19 + .../v2021_07_01/models/__init__.py | 145 + .../models/_application_client_enums.py | 163 + .../v2021_07_01/models/_models_py3.py | 2487 +++++++++++++++ .../v2021_07_01/models/_patch.py | 19 + .../v2021_07_01/operations/__init__.py | 24 + .../_application_client_operations.py | 134 + .../_application_definitions_operations.py | 1158 +++++++ .../operations/_applications_operations.py | 2090 +++++++++++++ .../operations/_jit_requests_operations.py | 736 +++++ .../v2021_07_01/operations/_patch.py | 19 + .../managedapplication/v2021_07_01/py.typed | 1 + .../sdk_packaging.toml | 9 + .../azure-mgmt-managedapplication/setup.py | 77 + sdk/managedapplication/ci.yml | 33 + 305 files changed, 94421 insertions(+) create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/CHANGELOG.md create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/LICENSE create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/MANIFEST.in create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/README.md create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/_meta.json create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/__init__.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/__init__.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/__init__.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/_application_client.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/_configuration.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/_operations_mixin.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/_version.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/aio/__init__.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/aio/_application_client.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/aio/_configuration.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/aio/_operations_mixin.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/models.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/py.typed create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_09_01/__init__.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_09_01/_application_client.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_09_01/_configuration.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_09_01/_metadata.json create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_09_01/_patch.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_09_01/_vendor.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_09_01/_version.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_09_01/aio/__init__.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_09_01/aio/_application_client.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_09_01/aio/_configuration.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_09_01/aio/_patch.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_09_01/aio/_vendor.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_09_01/aio/operations/__init__.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_09_01/aio/operations/_application_client_operations.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_09_01/aio/operations/_application_definitions_operations.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_09_01/aio/operations/_applications_operations.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_09_01/aio/operations/_patch.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_09_01/models/__init__.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_09_01/models/_application_client_enums.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_09_01/models/_models_py3.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_09_01/models/_patch.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_09_01/operations/__init__.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_09_01/operations/_application_client_operations.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_09_01/operations/_application_definitions_operations.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_09_01/operations/_applications_operations.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_09_01/operations/_patch.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_09_01/py.typed create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_12_01/__init__.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_12_01/_application_client.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_12_01/_configuration.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_12_01/_metadata.json create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_12_01/_patch.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_12_01/_vendor.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_12_01/_version.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_12_01/aio/__init__.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_12_01/aio/_application_client.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_12_01/aio/_configuration.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_12_01/aio/_patch.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_12_01/aio/_vendor.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_12_01/aio/operations/__init__.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_12_01/aio/operations/_application_client_operations.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_12_01/aio/operations/_application_definitions_operations.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_12_01/aio/operations/_applications_operations.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_12_01/aio/operations/_patch.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_12_01/models/__init__.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_12_01/models/_application_client_enums.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_12_01/models/_models_py3.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_12_01/models/_patch.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_12_01/operations/__init__.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_12_01/operations/_application_client_operations.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_12_01/operations/_application_definitions_operations.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_12_01/operations/_applications_operations.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_12_01/operations/_patch.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_12_01/py.typed create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_02_01/__init__.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_02_01/_application_client.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_02_01/_configuration.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_02_01/_metadata.json create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_02_01/_patch.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_02_01/_vendor.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_02_01/_version.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_02_01/aio/__init__.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_02_01/aio/_application_client.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_02_01/aio/_configuration.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_02_01/aio/_patch.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_02_01/aio/_vendor.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_02_01/aio/operations/__init__.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_02_01/aio/operations/_application_client_operations.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_02_01/aio/operations/_application_definitions_operations.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_02_01/aio/operations/_applications_operations.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_02_01/aio/operations/_patch.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_02_01/models/__init__.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_02_01/models/_application_client_enums.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_02_01/models/_models_py3.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_02_01/models/_patch.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_02_01/operations/__init__.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_02_01/operations/_application_client_operations.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_02_01/operations/_application_definitions_operations.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_02_01/operations/_applications_operations.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_02_01/operations/_patch.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_02_01/py.typed create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_03_01/__init__.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_03_01/_application_client.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_03_01/_configuration.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_03_01/_metadata.json create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_03_01/_patch.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_03_01/_vendor.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_03_01/_version.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_03_01/aio/__init__.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_03_01/aio/_application_client.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_03_01/aio/_configuration.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_03_01/aio/_patch.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_03_01/aio/_vendor.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_03_01/aio/operations/__init__.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_03_01/aio/operations/_application_client_operations.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_03_01/aio/operations/_application_definitions_operations.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_03_01/aio/operations/_applications_operations.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_03_01/aio/operations/_jit_requests_operations.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_03_01/aio/operations/_patch.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_03_01/models/__init__.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_03_01/models/_application_client_enums.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_03_01/models/_models_py3.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_03_01/models/_patch.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_03_01/operations/__init__.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_03_01/operations/_application_client_operations.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_03_01/operations/_application_definitions_operations.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_03_01/operations/_applications_operations.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_03_01/operations/_jit_requests_operations.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_03_01/operations/_patch.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_03_01/py.typed create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_06_01/__init__.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_06_01/_application_client.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_06_01/_configuration.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_06_01/_metadata.json create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_06_01/_patch.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_06_01/_vendor.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_06_01/_version.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_06_01/aio/__init__.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_06_01/aio/_application_client.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_06_01/aio/_configuration.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_06_01/aio/_patch.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_06_01/aio/_vendor.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_06_01/aio/operations/__init__.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_06_01/aio/operations/_application_client_operations.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_06_01/aio/operations/_application_definitions_operations.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_06_01/aio/operations/_applications_operations.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_06_01/aio/operations/_jit_requests_operations.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_06_01/aio/operations/_patch.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_06_01/models/__init__.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_06_01/models/_application_client_enums.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_06_01/models/_models_py3.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_06_01/models/_patch.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_06_01/operations/__init__.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_06_01/operations/_application_client_operations.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_06_01/operations/_application_definitions_operations.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_06_01/operations/_applications_operations.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_06_01/operations/_jit_requests_operations.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_06_01/operations/_patch.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_06_01/py.typed create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_09_01_preview/__init__.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_09_01_preview/_application_client.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_09_01_preview/_configuration.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_09_01_preview/_metadata.json create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_09_01_preview/_patch.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_09_01_preview/_vendor.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_09_01_preview/_version.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_09_01_preview/aio/__init__.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_09_01_preview/aio/_application_client.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_09_01_preview/aio/_configuration.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_09_01_preview/aio/_patch.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_09_01_preview/aio/_vendor.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_09_01_preview/aio/operations/__init__.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_09_01_preview/aio/operations/_application_client_operations.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_09_01_preview/aio/operations/_application_definitions_operations.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_09_01_preview/aio/operations/_applications_operations.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_09_01_preview/aio/operations/_jit_requests_operations.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_09_01_preview/aio/operations/_patch.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_09_01_preview/models/__init__.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_09_01_preview/models/_application_client_enums.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_09_01_preview/models/_models_py3.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_09_01_preview/models/_patch.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_09_01_preview/operations/__init__.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_09_01_preview/operations/_application_client_operations.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_09_01_preview/operations/_application_definitions_operations.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_09_01_preview/operations/_applications_operations.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_09_01_preview/operations/_jit_requests_operations.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_09_01_preview/operations/_patch.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_09_01_preview/py.typed create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2019_07_01/__init__.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2019_07_01/_application_client.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2019_07_01/_configuration.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2019_07_01/_metadata.json create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2019_07_01/_patch.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2019_07_01/_vendor.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2019_07_01/_version.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2019_07_01/aio/__init__.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2019_07_01/aio/_application_client.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2019_07_01/aio/_configuration.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2019_07_01/aio/_patch.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2019_07_01/aio/_vendor.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2019_07_01/aio/operations/__init__.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2019_07_01/aio/operations/_application_client_operations.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2019_07_01/aio/operations/_application_definitions_operations.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2019_07_01/aio/operations/_applications_operations.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2019_07_01/aio/operations/_jit_requests_operations.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2019_07_01/aio/operations/_patch.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2019_07_01/models/__init__.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2019_07_01/models/_application_client_enums.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2019_07_01/models/_models_py3.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2019_07_01/models/_patch.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2019_07_01/operations/__init__.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2019_07_01/operations/_application_client_operations.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2019_07_01/operations/_application_definitions_operations.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2019_07_01/operations/_applications_operations.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2019_07_01/operations/_jit_requests_operations.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2019_07_01/operations/_patch.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2019_07_01/py.typed create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2020_08_21_preview/__init__.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2020_08_21_preview/_application_client.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2020_08_21_preview/_configuration.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2020_08_21_preview/_metadata.json create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2020_08_21_preview/_patch.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2020_08_21_preview/_vendor.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2020_08_21_preview/_version.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2020_08_21_preview/aio/__init__.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2020_08_21_preview/aio/_application_client.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2020_08_21_preview/aio/_configuration.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2020_08_21_preview/aio/_patch.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2020_08_21_preview/aio/_vendor.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2020_08_21_preview/aio/operations/__init__.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2020_08_21_preview/aio/operations/_application_client_operations.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2020_08_21_preview/aio/operations/_application_definitions_operations.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2020_08_21_preview/aio/operations/_applications_operations.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2020_08_21_preview/aio/operations/_jit_requests_operations.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2020_08_21_preview/aio/operations/_patch.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2020_08_21_preview/models/__init__.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2020_08_21_preview/models/_application_client_enums.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2020_08_21_preview/models/_models_py3.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2020_08_21_preview/models/_patch.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2020_08_21_preview/operations/__init__.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2020_08_21_preview/operations/_application_client_operations.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2020_08_21_preview/operations/_application_definitions_operations.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2020_08_21_preview/operations/_applications_operations.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2020_08_21_preview/operations/_jit_requests_operations.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2020_08_21_preview/operations/_patch.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2020_08_21_preview/py.typed create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_02_01_preview/__init__.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_02_01_preview/_application_client.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_02_01_preview/_configuration.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_02_01_preview/_metadata.json create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_02_01_preview/_patch.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_02_01_preview/_vendor.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_02_01_preview/_version.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_02_01_preview/aio/__init__.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_02_01_preview/aio/_application_client.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_02_01_preview/aio/_configuration.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_02_01_preview/aio/_patch.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_02_01_preview/aio/_vendor.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_02_01_preview/aio/operations/__init__.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_02_01_preview/aio/operations/_application_client_operations.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_02_01_preview/aio/operations/_application_definitions_operations.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_02_01_preview/aio/operations/_applications_operations.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_02_01_preview/aio/operations/_jit_requests_operations.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_02_01_preview/aio/operations/_patch.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_02_01_preview/models/__init__.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_02_01_preview/models/_application_client_enums.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_02_01_preview/models/_models_py3.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_02_01_preview/models/_patch.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_02_01_preview/operations/__init__.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_02_01_preview/operations/_application_client_operations.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_02_01_preview/operations/_application_definitions_operations.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_02_01_preview/operations/_applications_operations.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_02_01_preview/operations/_jit_requests_operations.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_02_01_preview/operations/_patch.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_02_01_preview/py.typed create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_07_01/__init__.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_07_01/_application_client.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_07_01/_configuration.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_07_01/_metadata.json create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_07_01/_patch.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_07_01/_vendor.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_07_01/_version.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_07_01/aio/__init__.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_07_01/aio/_application_client.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_07_01/aio/_configuration.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_07_01/aio/_patch.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_07_01/aio/_vendor.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_07_01/aio/operations/__init__.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_07_01/aio/operations/_application_client_operations.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_07_01/aio/operations/_application_definitions_operations.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_07_01/aio/operations/_applications_operations.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_07_01/aio/operations/_jit_requests_operations.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_07_01/aio/operations/_patch.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_07_01/models/__init__.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_07_01/models/_application_client_enums.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_07_01/models/_models_py3.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_07_01/models/_patch.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_07_01/operations/__init__.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_07_01/operations/_application_client_operations.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_07_01/operations/_application_definitions_operations.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_07_01/operations/_applications_operations.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_07_01/operations/_jit_requests_operations.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_07_01/operations/_patch.py create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_07_01/py.typed create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/sdk_packaging.toml create mode 100644 sdk/managedapplication/azure-mgmt-managedapplication/setup.py create mode 100644 sdk/managedapplication/ci.yml diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/CHANGELOG.md b/sdk/managedapplication/azure-mgmt-managedapplication/CHANGELOG.md new file mode 100644 index 000000000000..578ed6acf479 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/CHANGELOG.md @@ -0,0 +1,5 @@ +# Release History + +## 0.1.0 (1970-01-01) + +* Initial Release diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/LICENSE b/sdk/managedapplication/azure-mgmt-managedapplication/LICENSE new file mode 100644 index 000000000000..b2f52a2bad4e --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/LICENSE @@ -0,0 +1,21 @@ +Copyright (c) Microsoft Corporation. + +MIT License + +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. diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/MANIFEST.in b/sdk/managedapplication/azure-mgmt-managedapplication/MANIFEST.in new file mode 100644 index 000000000000..0675ce8dfd88 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/MANIFEST.in @@ -0,0 +1,7 @@ +include _meta.json +recursive-include tests *.py *.json +include *.md +include azure/__init__.py +include azure/mgmt/__init__.py +include LICENSE +include azure/mgmt/managedapplication/py.typed diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/README.md b/sdk/managedapplication/azure-mgmt-managedapplication/README.md new file mode 100644 index 000000000000..9880a42e86dc --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/README.md @@ -0,0 +1,30 @@ +# Microsoft Azure SDK for Python + +This is the Microsoft Azure MyService Management Client Library. +This package has been tested with Python 3.7+. +For a more complete view of Azure libraries, see the [azure sdk python release](https://aka.ms/azsdk/python/all). + +## _Disclaimer_ + +_Azure SDK Python packages support for Python 2.7 has ended 01 January 2022. For more information and questions, please refer to https://github.com/Azure/azure-sdk-for-python/issues/20691_ + +# Usage + + +To learn how to use this package, see the [quickstart guide](https://aka.ms/azsdk/python/mgmt) + + + +For docs and references, see [Python SDK References](https://docs.microsoft.com/python/api/overview/azure/) +Code samples for this package can be found at [MyService Management](https://docs.microsoft.com/samples/browse/?languages=python&term=Getting%20started%20-%20Managing&terms=Getting%20started%20-%20Managing) on docs.microsoft.com. +Additional code samples for different Azure services are available at [Samples Repo](https://aka.ms/azsdk/python/mgmt/samples) + + +# Provide Feedback + +If you encounter any bugs or have suggestions, please file an issue in the +[Issues](https://github.com/Azure/azure-sdk-for-python/issues) +section of the project. + + +![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-python%2Fazure-mgmt-managedapplication%2FREADME.png) diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/_meta.json b/sdk/managedapplication/azure-mgmt-managedapplication/_meta.json new file mode 100644 index 000000000000..453fdbfe0c90 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/_meta.json @@ -0,0 +1,11 @@ +{ + "autorest": "3.7.2", + "use": [ + "@autorest/python@5.16.0", + "@autorest/modelerfour@4.19.3" + ], + "commit": "83b8281a57c64951dc6ceb0619e3607e3fd77194", + "repository_url": "https://github.com/Azure/azure-rest-api-specs", + "autorest_command": "autorest specification/solutions/resource-manager/readme.md --python --python-sdks-folder=/mnt/vss/_work/1/s/azure-sdk-for-python/sdk --python3-only --use=@autorest/python@5.16.0 --use=@autorest/modelerfour@4.19.3 --version=3.7.2", + "readme": "specification/solutions/resource-manager/readme.md" +} \ No newline at end of file diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/__init__.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/__init__.py new file mode 100644 index 000000000000..8db66d3d0f0f --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/__init__.py @@ -0,0 +1 @@ +__path__ = __import__("pkgutil").extend_path(__path__, __name__) diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/__init__.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/__init__.py new file mode 100644 index 000000000000..8db66d3d0f0f --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/__init__.py @@ -0,0 +1 @@ +__path__ = __import__("pkgutil").extend_path(__path__, __name__) diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/__init__.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/__init__.py new file mode 100644 index 000000000000..ab8aa89a6497 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/__init__.py @@ -0,0 +1,16 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._application_client import ApplicationClient +__all__ = ['ApplicationClient'] + +try: + from ._patch import patch_sdk # type: ignore + patch_sdk() +except ImportError: + pass diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/_application_client.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/_application_client.py new file mode 100644 index 000000000000..c2887e97f450 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/_application_client.py @@ -0,0 +1,253 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from typing import TYPE_CHECKING + +from msrest import Deserializer, Serializer + +from azure.mgmt.core import ARMPipelineClient +from azure.profiles import KnownProfiles, ProfileDefinition +from azure.profiles.multiapiclient import MultiApiClientMixin + +from ._configuration import ApplicationClientConfiguration +from ._operations_mixin import ApplicationClientOperationsMixin + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + + from azure.core.credentials import TokenCredential + +class _SDKClient(object): + def __init__(self, *args, **kwargs): + """This is a fake class to support current implemetation of MultiApiClientMixin." + Will be removed in final version of multiapi azure-core based client + """ + pass + +class ApplicationClient(ApplicationClientOperationsMixin, MultiApiClientMixin, _SDKClient): + """ARM applications. + + This ready contains multiple API versions, to help you deal with all of the Azure clouds + (Azure Stack, Azure Government, Azure China, etc.). + By default, it uses the latest API version available on public Azure. + For production, you should stick to a particular api-version and/or profile. + The profile sets a mapping between an operation group and its API version. + The api-version parameter sets the default API version if the operation + group is not described in the profile. + + :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 + :type base_url: str + :param profile: A profile definition, from KnownProfiles to dict. + :type profile: azure.profiles.KnownProfiles + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + """ + + DEFAULT_API_VERSION = '2021-07-01' + _PROFILE_TAG = "azure.mgmt.managedapplication.ApplicationClient" + LATEST_PROFILE = ProfileDefinition({ + _PROFILE_TAG: { + None: DEFAULT_API_VERSION, + }}, + _PROFILE_TAG + " latest" + ) + + def __init__( + self, + credential, # type: "TokenCredential" + subscription_id, # type: str + api_version=None, # type: Optional[str] + base_url="https://management.azure.com", # type: str + profile=KnownProfiles.default, # type: KnownProfiles + **kwargs # type: Any + ): + self._config = ApplicationClientConfiguration(credential, subscription_id, **kwargs) + self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + super(ApplicationClient, self).__init__( + api_version=api_version, + profile=profile + ) + + @classmethod + def _models_dict(cls, api_version): + return {k: v for k, v in cls.models(api_version).__dict__.items() if isinstance(v, type)} + + @classmethod + def models(cls, api_version=DEFAULT_API_VERSION): + """Module depends on the API version: + + * 2017-09-01: :mod:`v2017_09_01.models` + * 2017-12-01: :mod:`v2017_12_01.models` + * 2018-02-01: :mod:`v2018_02_01.models` + * 2018-03-01: :mod:`v2018_03_01.models` + * 2018-06-01: :mod:`v2018_06_01.models` + * 2018-09-01-preview: :mod:`v2018_09_01_preview.models` + * 2019-07-01: :mod:`v2019_07_01.models` + * 2020-08-21-preview: :mod:`v2020_08_21_preview.models` + * 2021-02-01-preview: :mod:`v2021_02_01_preview.models` + * 2021-07-01: :mod:`v2021_07_01.models` + """ + if api_version == '2017-09-01': + from .v2017_09_01 import models + return models + elif api_version == '2017-12-01': + from .v2017_12_01 import models + return models + elif api_version == '2018-02-01': + from .v2018_02_01 import models + return models + elif api_version == '2018-03-01': + from .v2018_03_01 import models + return models + elif api_version == '2018-06-01': + from .v2018_06_01 import models + return models + elif api_version == '2018-09-01-preview': + from .v2018_09_01_preview import models + return models + elif api_version == '2019-07-01': + from .v2019_07_01 import models + return models + elif api_version == '2020-08-21-preview': + from .v2020_08_21_preview import models + return models + elif api_version == '2021-02-01-preview': + from .v2021_02_01_preview import models + return models + elif api_version == '2021-07-01': + from .v2021_07_01 import models + return models + raise ValueError("API version {} is not available".format(api_version)) + + @property + def application_definitions(self): + """Instance depends on the API version: + + * 2017-09-01: :class:`ApplicationDefinitionsOperations` + * 2017-12-01: :class:`ApplicationDefinitionsOperations` + * 2018-02-01: :class:`ApplicationDefinitionsOperations` + * 2018-03-01: :class:`ApplicationDefinitionsOperations` + * 2018-06-01: :class:`ApplicationDefinitionsOperations` + * 2018-09-01-preview: :class:`ApplicationDefinitionsOperations` + * 2019-07-01: :class:`ApplicationDefinitionsOperations` + * 2020-08-21-preview: :class:`ApplicationDefinitionsOperations` + * 2021-02-01-preview: :class:`ApplicationDefinitionsOperations` + * 2021-07-01: :class:`ApplicationDefinitionsOperations` + """ + api_version = self._get_api_version('application_definitions') + if api_version == '2017-09-01': + from .v2017_09_01.operations import ApplicationDefinitionsOperations as OperationClass + elif api_version == '2017-12-01': + from .v2017_12_01.operations import ApplicationDefinitionsOperations as OperationClass + elif api_version == '2018-02-01': + from .v2018_02_01.operations import ApplicationDefinitionsOperations as OperationClass + elif api_version == '2018-03-01': + from .v2018_03_01.operations import ApplicationDefinitionsOperations as OperationClass + elif api_version == '2018-06-01': + from .v2018_06_01.operations import ApplicationDefinitionsOperations as OperationClass + elif api_version == '2018-09-01-preview': + from .v2018_09_01_preview.operations import ApplicationDefinitionsOperations as OperationClass + elif api_version == '2019-07-01': + from .v2019_07_01.operations import ApplicationDefinitionsOperations as OperationClass + elif api_version == '2020-08-21-preview': + from .v2020_08_21_preview.operations import ApplicationDefinitionsOperations as OperationClass + elif api_version == '2021-02-01-preview': + from .v2021_02_01_preview.operations import ApplicationDefinitionsOperations as OperationClass + elif api_version == '2021-07-01': + from .v2021_07_01.operations import ApplicationDefinitionsOperations as OperationClass + else: + raise ValueError("API version {} does not have operation group 'application_definitions'".format(api_version)) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + + @property + def applications(self): + """Instance depends on the API version: + + * 2017-09-01: :class:`ApplicationsOperations` + * 2017-12-01: :class:`ApplicationsOperations` + * 2018-02-01: :class:`ApplicationsOperations` + * 2018-03-01: :class:`ApplicationsOperations` + * 2018-06-01: :class:`ApplicationsOperations` + * 2018-09-01-preview: :class:`ApplicationsOperations` + * 2019-07-01: :class:`ApplicationsOperations` + * 2020-08-21-preview: :class:`ApplicationsOperations` + * 2021-02-01-preview: :class:`ApplicationsOperations` + * 2021-07-01: :class:`ApplicationsOperations` + """ + api_version = self._get_api_version('applications') + if api_version == '2017-09-01': + from .v2017_09_01.operations import ApplicationsOperations as OperationClass + elif api_version == '2017-12-01': + from .v2017_12_01.operations import ApplicationsOperations as OperationClass + elif api_version == '2018-02-01': + from .v2018_02_01.operations import ApplicationsOperations as OperationClass + elif api_version == '2018-03-01': + from .v2018_03_01.operations import ApplicationsOperations as OperationClass + elif api_version == '2018-06-01': + from .v2018_06_01.operations import ApplicationsOperations as OperationClass + elif api_version == '2018-09-01-preview': + from .v2018_09_01_preview.operations import ApplicationsOperations as OperationClass + elif api_version == '2019-07-01': + from .v2019_07_01.operations import ApplicationsOperations as OperationClass + elif api_version == '2020-08-21-preview': + from .v2020_08_21_preview.operations import ApplicationsOperations as OperationClass + elif api_version == '2021-02-01-preview': + from .v2021_02_01_preview.operations import ApplicationsOperations as OperationClass + elif api_version == '2021-07-01': + from .v2021_07_01.operations import ApplicationsOperations as OperationClass + else: + raise ValueError("API version {} does not have operation group 'applications'".format(api_version)) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + + @property + def jit_requests(self): + """Instance depends on the API version: + + * 2018-03-01: :class:`JitRequestsOperations` + * 2018-06-01: :class:`JitRequestsOperations` + * 2018-09-01-preview: :class:`JitRequestsOperations` + * 2019-07-01: :class:`JitRequestsOperations` + * 2020-08-21-preview: :class:`JitRequestsOperations` + * 2021-02-01-preview: :class:`JitRequestsOperations` + * 2021-07-01: :class:`JitRequestsOperations` + """ + api_version = self._get_api_version('jit_requests') + if api_version == '2018-03-01': + from .v2018_03_01.operations import JitRequestsOperations as OperationClass + elif api_version == '2018-06-01': + from .v2018_06_01.operations import JitRequestsOperations as OperationClass + elif api_version == '2018-09-01-preview': + from .v2018_09_01_preview.operations import JitRequestsOperations as OperationClass + elif api_version == '2019-07-01': + from .v2019_07_01.operations import JitRequestsOperations as OperationClass + elif api_version == '2020-08-21-preview': + from .v2020_08_21_preview.operations import JitRequestsOperations as OperationClass + elif api_version == '2021-02-01-preview': + from .v2021_02_01_preview.operations import JitRequestsOperations as OperationClass + elif api_version == '2021-07-01': + from .v2021_07_01.operations import JitRequestsOperations as OperationClass + else: + raise ValueError("API version {} does not have operation group 'jit_requests'".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): + self._client.__enter__() + return self + def __exit__(self, *exc_details): + self._client.__exit__(*exc_details) diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/_configuration.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/_configuration.py new file mode 100644 index 000000000000..2bab77194439 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/_configuration.py @@ -0,0 +1,71 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- +from typing import TYPE_CHECKING + +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 typing import Any + + from azure.core.credentials import TokenCredential + +class ApplicationClientConfiguration(Configuration): + """Configuration for ApplicationClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials.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(ApplicationClientConfiguration, 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-managedapplication/{}'.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/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/_operations_mixin.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/_operations_mixin.py new file mode 100644 index 000000000000..ca0e53785e29 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/_operations_mixin.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 msrest import Serializer, Deserializer +from typing import TYPE_CHECKING + +from . import models as _models + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Iterable + + from azure.core.paging import ItemPaged + + +class ApplicationClientOperationsMixin(object): + + def list_operations( + self, + **kwargs # type: Any + ): + # type: (...) -> Iterable[_models.OperationListResult] + """Lists all of the available Microsoft.Solutions REST API operations. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either OperationListResult or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.managedapplication.v2021_07_01.models.OperationListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = self._get_api_version('list_operations') + if api_version == '2017-09-01': + from .v2017_09_01.operations import ApplicationClientOperationsMixin as OperationClass + elif api_version == '2017-12-01': + from .v2017_12_01.operations import ApplicationClientOperationsMixin as OperationClass + elif api_version == '2018-02-01': + from .v2018_02_01.operations import ApplicationClientOperationsMixin as OperationClass + elif api_version == '2018-03-01': + from .v2018_03_01.operations import ApplicationClientOperationsMixin as OperationClass + elif api_version == '2018-06-01': + from .v2018_06_01.operations import ApplicationClientOperationsMixin as OperationClass + elif api_version == '2018-09-01-preview': + from .v2018_09_01_preview.operations import ApplicationClientOperationsMixin as OperationClass + elif api_version == '2019-07-01': + from .v2019_07_01.operations import ApplicationClientOperationsMixin as OperationClass + elif api_version == '2020-08-21-preview': + from .v2020_08_21_preview.operations import ApplicationClientOperationsMixin as OperationClass + elif api_version == '2021-02-01-preview': + from .v2021_02_01_preview.operations import ApplicationClientOperationsMixin as OperationClass + elif api_version == '2021-07-01': + from .v2021_07_01.operations import ApplicationClientOperationsMixin as OperationClass + else: + raise ValueError("API version {} does not have operation 'list_operations'".format(api_version)) + mixin_instance = OperationClass() + mixin_instance._client = self._client + mixin_instance._config = self._config + mixin_instance._serialize = Serializer(self._models_dict(api_version)) + mixin_instance._serialize.client_side_validation = False + mixin_instance._deserialize = Deserializer(self._models_dict(api_version)) + return mixin_instance.list_operations(**kwargs) diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/_version.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/_version.py new file mode 100644 index 000000000000..a30a458f8b5b --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/_version.py @@ -0,0 +1,8 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# -------------------------------------------------------------------------- + +VERSION = "0.1.0" \ No newline at end of file diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/aio/__init__.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/aio/__init__.py new file mode 100644 index 000000000000..42ac8700d5df --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/aio/__init__.py @@ -0,0 +1,10 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._application_client import ApplicationClient +__all__ = ['ApplicationClient'] diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/aio/_application_client.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/aio/_application_client.py new file mode 100644 index 000000000000..0291fd4dba4f --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/aio/_application_client.py @@ -0,0 +1,252 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from typing import Any, Optional, TYPE_CHECKING + +from msrest import Deserializer, Serializer + +from azure.mgmt.core import AsyncARMPipelineClient +from azure.profiles import KnownProfiles, ProfileDefinition +from azure.profiles.multiapiclient import MultiApiClientMixin + +from ._configuration import ApplicationClientConfiguration +from ._operations_mixin import ApplicationClientOperationsMixin + +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): + def __init__(self, *args, **kwargs): + """This is a fake class to support current implemetation of MultiApiClientMixin." + Will be removed in final version of multiapi azure-core based client + """ + pass + +class ApplicationClient(ApplicationClientOperationsMixin, MultiApiClientMixin, _SDKClient): + """ARM applications. + + This ready contains multiple API versions, to help you deal with all of the Azure clouds + (Azure Stack, Azure Government, Azure China, etc.). + By default, it uses the latest API version available on public Azure. + For production, you should stick to a particular api-version and/or profile. + The profile sets a mapping between an operation group and its API version. + The api-version parameter sets the default API version if the operation + group is not described in the profile. + + :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 + :type base_url: str + :param profile: A profile definition, from KnownProfiles to dict. + :type profile: azure.profiles.KnownProfiles + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + """ + + DEFAULT_API_VERSION = '2021-07-01' + _PROFILE_TAG = "azure.mgmt.managedapplication.ApplicationClient" + LATEST_PROFILE = ProfileDefinition({ + _PROFILE_TAG: { + None: DEFAULT_API_VERSION, + }}, + _PROFILE_TAG + " latest" + ) + + def __init__( + self, + credential: "AsyncTokenCredential", + subscription_id: str, + api_version: Optional[str] = None, + base_url: str = "https://management.azure.com", + profile: KnownProfiles = KnownProfiles.default, + **kwargs # type: Any + ) -> None: + self._config = ApplicationClientConfiguration(credential, subscription_id, **kwargs) + self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + super(ApplicationClient, self).__init__( + api_version=api_version, + profile=profile + ) + + @classmethod + def _models_dict(cls, api_version): + return {k: v for k, v in cls.models(api_version).__dict__.items() if isinstance(v, type)} + + @classmethod + def models(cls, api_version=DEFAULT_API_VERSION): + """Module depends on the API version: + + * 2017-09-01: :mod:`v2017_09_01.models` + * 2017-12-01: :mod:`v2017_12_01.models` + * 2018-02-01: :mod:`v2018_02_01.models` + * 2018-03-01: :mod:`v2018_03_01.models` + * 2018-06-01: :mod:`v2018_06_01.models` + * 2018-09-01-preview: :mod:`v2018_09_01_preview.models` + * 2019-07-01: :mod:`v2019_07_01.models` + * 2020-08-21-preview: :mod:`v2020_08_21_preview.models` + * 2021-02-01-preview: :mod:`v2021_02_01_preview.models` + * 2021-07-01: :mod:`v2021_07_01.models` + """ + if api_version == '2017-09-01': + from ..v2017_09_01 import models + return models + elif api_version == '2017-12-01': + from ..v2017_12_01 import models + return models + elif api_version == '2018-02-01': + from ..v2018_02_01 import models + return models + elif api_version == '2018-03-01': + from ..v2018_03_01 import models + return models + elif api_version == '2018-06-01': + from ..v2018_06_01 import models + return models + elif api_version == '2018-09-01-preview': + from ..v2018_09_01_preview import models + return models + elif api_version == '2019-07-01': + from ..v2019_07_01 import models + return models + elif api_version == '2020-08-21-preview': + from ..v2020_08_21_preview import models + return models + elif api_version == '2021-02-01-preview': + from ..v2021_02_01_preview import models + return models + elif api_version == '2021-07-01': + from ..v2021_07_01 import models + return models + raise ValueError("API version {} is not available".format(api_version)) + + @property + def application_definitions(self): + """Instance depends on the API version: + + * 2017-09-01: :class:`ApplicationDefinitionsOperations` + * 2017-12-01: :class:`ApplicationDefinitionsOperations` + * 2018-02-01: :class:`ApplicationDefinitionsOperations` + * 2018-03-01: :class:`ApplicationDefinitionsOperations` + * 2018-06-01: :class:`ApplicationDefinitionsOperations` + * 2018-09-01-preview: :class:`ApplicationDefinitionsOperations` + * 2019-07-01: :class:`ApplicationDefinitionsOperations` + * 2020-08-21-preview: :class:`ApplicationDefinitionsOperations` + * 2021-02-01-preview: :class:`ApplicationDefinitionsOperations` + * 2021-07-01: :class:`ApplicationDefinitionsOperations` + """ + api_version = self._get_api_version('application_definitions') + if api_version == '2017-09-01': + from ..v2017_09_01.aio.operations import ApplicationDefinitionsOperations as OperationClass + elif api_version == '2017-12-01': + from ..v2017_12_01.aio.operations import ApplicationDefinitionsOperations as OperationClass + elif api_version == '2018-02-01': + from ..v2018_02_01.aio.operations import ApplicationDefinitionsOperations as OperationClass + elif api_version == '2018-03-01': + from ..v2018_03_01.aio.operations import ApplicationDefinitionsOperations as OperationClass + elif api_version == '2018-06-01': + from ..v2018_06_01.aio.operations import ApplicationDefinitionsOperations as OperationClass + elif api_version == '2018-09-01-preview': + from ..v2018_09_01_preview.aio.operations import ApplicationDefinitionsOperations as OperationClass + elif api_version == '2019-07-01': + from ..v2019_07_01.aio.operations import ApplicationDefinitionsOperations as OperationClass + elif api_version == '2020-08-21-preview': + from ..v2020_08_21_preview.aio.operations import ApplicationDefinitionsOperations as OperationClass + elif api_version == '2021-02-01-preview': + from ..v2021_02_01_preview.aio.operations import ApplicationDefinitionsOperations as OperationClass + elif api_version == '2021-07-01': + from ..v2021_07_01.aio.operations import ApplicationDefinitionsOperations as OperationClass + else: + raise ValueError("API version {} does not have operation group 'application_definitions'".format(api_version)) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + + @property + def applications(self): + """Instance depends on the API version: + + * 2017-09-01: :class:`ApplicationsOperations` + * 2017-12-01: :class:`ApplicationsOperations` + * 2018-02-01: :class:`ApplicationsOperations` + * 2018-03-01: :class:`ApplicationsOperations` + * 2018-06-01: :class:`ApplicationsOperations` + * 2018-09-01-preview: :class:`ApplicationsOperations` + * 2019-07-01: :class:`ApplicationsOperations` + * 2020-08-21-preview: :class:`ApplicationsOperations` + * 2021-02-01-preview: :class:`ApplicationsOperations` + * 2021-07-01: :class:`ApplicationsOperations` + """ + api_version = self._get_api_version('applications') + if api_version == '2017-09-01': + from ..v2017_09_01.aio.operations import ApplicationsOperations as OperationClass + elif api_version == '2017-12-01': + from ..v2017_12_01.aio.operations import ApplicationsOperations as OperationClass + elif api_version == '2018-02-01': + from ..v2018_02_01.aio.operations import ApplicationsOperations as OperationClass + elif api_version == '2018-03-01': + from ..v2018_03_01.aio.operations import ApplicationsOperations as OperationClass + elif api_version == '2018-06-01': + from ..v2018_06_01.aio.operations import ApplicationsOperations as OperationClass + elif api_version == '2018-09-01-preview': + from ..v2018_09_01_preview.aio.operations import ApplicationsOperations as OperationClass + elif api_version == '2019-07-01': + from ..v2019_07_01.aio.operations import ApplicationsOperations as OperationClass + elif api_version == '2020-08-21-preview': + from ..v2020_08_21_preview.aio.operations import ApplicationsOperations as OperationClass + elif api_version == '2021-02-01-preview': + from ..v2021_02_01_preview.aio.operations import ApplicationsOperations as OperationClass + elif api_version == '2021-07-01': + from ..v2021_07_01.aio.operations import ApplicationsOperations as OperationClass + else: + raise ValueError("API version {} does not have operation group 'applications'".format(api_version)) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + + @property + def jit_requests(self): + """Instance depends on the API version: + + * 2018-03-01: :class:`JitRequestsOperations` + * 2018-06-01: :class:`JitRequestsOperations` + * 2018-09-01-preview: :class:`JitRequestsOperations` + * 2019-07-01: :class:`JitRequestsOperations` + * 2020-08-21-preview: :class:`JitRequestsOperations` + * 2021-02-01-preview: :class:`JitRequestsOperations` + * 2021-07-01: :class:`JitRequestsOperations` + """ + api_version = self._get_api_version('jit_requests') + if api_version == '2018-03-01': + from ..v2018_03_01.aio.operations import JitRequestsOperations as OperationClass + elif api_version == '2018-06-01': + from ..v2018_06_01.aio.operations import JitRequestsOperations as OperationClass + elif api_version == '2018-09-01-preview': + from ..v2018_09_01_preview.aio.operations import JitRequestsOperations as OperationClass + elif api_version == '2019-07-01': + from ..v2019_07_01.aio.operations import JitRequestsOperations as OperationClass + elif api_version == '2020-08-21-preview': + from ..v2020_08_21_preview.aio.operations import JitRequestsOperations as OperationClass + elif api_version == '2021-02-01-preview': + from ..v2021_02_01_preview.aio.operations import JitRequestsOperations as OperationClass + elif api_version == '2021-07-01': + from ..v2021_07_01.aio.operations import JitRequestsOperations as OperationClass + else: + raise ValueError("API version {} does not have operation group 'jit_requests'".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): + await self._client.__aenter__() + return self + async def __aexit__(self, *exc_details): + await self._client.__aexit__(*exc_details) diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/aio/_configuration.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/aio/_configuration.py new file mode 100644 index 000000000000..8a5bebe00acd --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/aio/_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 ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy + +from .._version import VERSION + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + +class ApplicationClientConfiguration(Configuration): + """Configuration for ApplicationClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :param subscription_id: The ID of the target subscription. + :type subscription_id: str + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + subscription_id: str, + **kwargs # 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(ApplicationClientConfiguration, 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-managedapplication/{}'.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/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/aio/_operations_mixin.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/aio/_operations_mixin.py new file mode 100644 index 000000000000..ac25f69545e7 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/aio/_operations_mixin.py @@ -0,0 +1,62 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- +from msrest import Serializer, Deserializer +from typing import Any, AsyncIterable + +from azure.core.async_paging import AsyncItemPaged + +from .. import models as _models + + +class ApplicationClientOperationsMixin(object): + + def list_operations( + self, + **kwargs: Any + ) -> AsyncIterable[_models.OperationListResult]: + """Lists all of the available Microsoft.Solutions REST API operations. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either OperationListResult or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.managedapplication.v2021_07_01.models.OperationListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = self._get_api_version('list_operations') + if api_version == '2017-09-01': + from ..v2017_09_01.aio.operations import ApplicationClientOperationsMixin as OperationClass + elif api_version == '2017-12-01': + from ..v2017_12_01.aio.operations import ApplicationClientOperationsMixin as OperationClass + elif api_version == '2018-02-01': + from ..v2018_02_01.aio.operations import ApplicationClientOperationsMixin as OperationClass + elif api_version == '2018-03-01': + from ..v2018_03_01.aio.operations import ApplicationClientOperationsMixin as OperationClass + elif api_version == '2018-06-01': + from ..v2018_06_01.aio.operations import ApplicationClientOperationsMixin as OperationClass + elif api_version == '2018-09-01-preview': + from ..v2018_09_01_preview.aio.operations import ApplicationClientOperationsMixin as OperationClass + elif api_version == '2019-07-01': + from ..v2019_07_01.aio.operations import ApplicationClientOperationsMixin as OperationClass + elif api_version == '2020-08-21-preview': + from ..v2020_08_21_preview.aio.operations import ApplicationClientOperationsMixin as OperationClass + elif api_version == '2021-02-01-preview': + from ..v2021_02_01_preview.aio.operations import ApplicationClientOperationsMixin as OperationClass + elif api_version == '2021-07-01': + from ..v2021_07_01.aio.operations import ApplicationClientOperationsMixin as OperationClass + else: + raise ValueError("API version {} does not have operation 'list_operations'".format(api_version)) + mixin_instance = OperationClass() + mixin_instance._client = self._client + mixin_instance._config = self._config + mixin_instance._serialize = Serializer(self._models_dict(api_version)) + mixin_instance._serialize.client_side_validation = False + mixin_instance._deserialize = Deserializer(self._models_dict(api_version)) + return mixin_instance.list_operations(**kwargs) diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/models.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/models.py new file mode 100644 index 000000000000..059efe06ada8 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/models.py @@ -0,0 +1,7 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# -------------------------------------------------------------------------- +from .v2021_07_01.models import * diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/py.typed b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/py.typed new file mode 100644 index 000000000000..e5aff4f83af8 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_09_01/__init__.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_09_01/__init__.py new file mode 100644 index 000000000000..2e61ca12e56a --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_09_01/__init__.py @@ -0,0 +1,23 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._application_client import ApplicationClient +from ._version import VERSION + +__version__ = VERSION + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk +__all__ = ['ApplicationClient'] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_09_01/_application_client.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_09_01/_application_client.py new file mode 100644 index 000000000000..8ae948e40997 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_09_01/_application_client.py @@ -0,0 +1,106 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from 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 ApplicationClientConfiguration +from .operations import ApplicationClientOperationsMixin, ApplicationDefinitionsOperations, ApplicationsOperations + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential + +class ApplicationClient(ApplicationClientOperationsMixin): + """ARM applications. + + :ivar applications: ApplicationsOperations operations + :vartype applications: + azure.mgmt.managedapplication.v2017_09_01.operations.ApplicationsOperations + :ivar application_definitions: ApplicationDefinitionsOperations operations + :vartype application_definitions: + azure.mgmt.managedapplication.v2017_09_01.operations.ApplicationDefinitionsOperations + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials.TokenCredential + :param subscription_id: The ID of the target subscription. + :type subscription_id: str + :param base_url: Service URL. Default value is "https://management.azure.com". + :type base_url: str + :keyword api_version: Api Version. Default value is "2017-09-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + """ + + def __init__( + self, + credential: "TokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = ApplicationClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.applications = ApplicationsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.application_definitions = ApplicationDefinitionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + + + 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: () -> ApplicationClient + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (Any) -> None + self._client.__exit__(*exc_details) diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_09_01/_configuration.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_09_01/_configuration.py new file mode 100644 index 000000000000..e7b52d4a07b4 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_09_01/_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 ApplicationClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes + """Configuration for ApplicationClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials.TokenCredential + :param subscription_id: The ID of the target subscription. + :type subscription_id: str + :keyword api_version: Api Version. Default value is "2017-09-01". 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(ApplicationClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2017-09-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.") + + 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-managedapplication/{}'.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/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_09_01/_metadata.json b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_09_01/_metadata.json new file mode 100644 index 000000000000..7e799676e0de --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_09_01/_metadata.json @@ -0,0 +1,122 @@ +{ + "chosen_version": "2017-09-01", + "total_api_version_list": ["2017-09-01"], + "client": { + "name": "ApplicationClient", + "filename": "_application_client", + "description": "ARM applications.", + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": null, + "azure_arm": true, + "has_lro_operations": true, + "client_side_validation": false, + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ApplicationClientConfiguration\"], \"._operations_mixin\": [\"ApplicationClientOperationsMixin\"]}, \"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\": [\"ApplicationClientConfiguration\"], \"._operations_mixin\": [\"ApplicationClientOperationsMixin\"]}, \"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": { + "applications": "ApplicationsOperations", + "application_definitions": "ApplicationDefinitionsOperations" + }, + "operation_mixins": { + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Iterable\"]}, \"azurecore\": {\"azure.core.paging\": [\"ItemPaged\"]}}, \"regular\": {\"local\": {\".\": [[\"models\", \"_models\"]]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"AsyncIterable\"]}, \"azurecore\": {\"azure.core.async_paging\": [\"AsyncItemPaged\"]}}, \"regular\": {\"local\": {\"..\": [[\"models\", \"_models\"]]}}}", + "operations": { + "list_operations" : { + "sync": { + "signature": "def list_operations(\n self,\n **kwargs # type: Any\n):\n # type: (...) -\u003e Iterable[_models.OperationListResult]\n", + "doc": "\"\"\"Lists all of the available Microsoft.Solutions REST API operations.\n\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: An iterator like instance of either OperationListResult or the result of cls(response)\n:rtype:\n ~azure.core.paging.ItemPaged[~azure.mgmt.managedapplication.v2017_09_01.models.OperationListResult]\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"", + "call": "**kwargs" + }, + "async": { + "coroutine": false, + "signature": "def list_operations(\n self,\n **kwargs: Any\n) -\u003e AsyncIterable[_models.OperationListResult]:\n", + "doc": "\"\"\"Lists all of the available Microsoft.Solutions REST API operations.\n\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: An iterator like instance of either OperationListResult or the result of cls(response)\n:rtype:\n ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.managedapplication.v2017_09_01.models.OperationListResult]\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"", + "call": "**kwargs" + } + } + } + } +} \ No newline at end of file diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_09_01/_patch.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_09_01/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_09_01/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_09_01/_vendor.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_09_01/_vendor.py new file mode 100644 index 000000000000..bf1845cabc0f --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_09_01/_vendor.py @@ -0,0 +1,45 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from abc import ABC +from typing import TYPE_CHECKING + +from azure.core.pipeline.transport import HttpRequest + +from ._configuration import ApplicationClientConfiguration + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from msrest import Deserializer, Serializer + + from azure.core import PipelineClient + +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) + +class MixinABC(ABC): + """DO NOT use this class. It is for internal typing use only.""" + _client: "PipelineClient" + _config: ApplicationClientConfiguration + _serialize: "Serializer" + _deserialize: "Deserializer" diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_09_01/_version.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_09_01/_version.py new file mode 100644 index 000000000000..e5754a47ce68 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_09_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/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_09_01/aio/__init__.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_09_01/aio/__init__.py new file mode 100644 index 000000000000..c90626a31421 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_09_01/aio/__init__.py @@ -0,0 +1,20 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._application_client import ApplicationClient + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk +__all__ = ['ApplicationClient'] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_09_01/aio/_application_client.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_09_01/aio/_application_client.py new file mode 100644 index 000000000000..facbd5bcff2b --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_09_01/aio/_application_client.py @@ -0,0 +1,103 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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 ApplicationClientConfiguration +from .operations import ApplicationClientOperationsMixin, ApplicationDefinitionsOperations, ApplicationsOperations + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + +class ApplicationClient(ApplicationClientOperationsMixin): + """ARM applications. + + :ivar applications: ApplicationsOperations operations + :vartype applications: + azure.mgmt.managedapplication.v2017_09_01.aio.operations.ApplicationsOperations + :ivar application_definitions: ApplicationDefinitionsOperations operations + :vartype application_definitions: + azure.mgmt.managedapplication.v2017_09_01.aio.operations.ApplicationDefinitionsOperations + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :param subscription_id: The ID of the target subscription. + :type subscription_id: str + :param base_url: Service URL. Default value is "https://management.azure.com". + :type base_url: str + :keyword api_version: Api Version. Default value is "2017-09-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = ApplicationClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.applications = ApplicationsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.application_definitions = ApplicationDefinitionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + + + 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) -> "ApplicationClient": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_09_01/aio/_configuration.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_09_01/aio/_configuration.py new file mode 100644 index 000000000000..0f5c209870a3 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_09_01/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 ApplicationClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes + """Configuration for ApplicationClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :param subscription_id: The ID of the target subscription. + :type subscription_id: str + :keyword api_version: Api Version. Default value is "2017-09-01". 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(ApplicationClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2017-09-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.") + + 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-managedapplication/{}'.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/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_09_01/aio/_patch.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_09_01/aio/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_09_01/aio/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_09_01/aio/_vendor.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_09_01/aio/_vendor.py new file mode 100644 index 000000000000..da14e4f71f0e --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_09_01/aio/_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 abc import ABC +from typing import TYPE_CHECKING + +from azure.core.pipeline.transport import HttpRequest + +from ._configuration import ApplicationClientConfiguration + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from msrest import Deserializer, Serializer + + from azure.core import AsyncPipelineClient + + +class MixinABC(ABC): + """DO NOT use this class. It is for internal typing use only.""" + _client: "AsyncPipelineClient" + _config: ApplicationClientConfiguration + _serialize: "Serializer" + _deserialize: "Deserializer" diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_09_01/aio/operations/__init__.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_09_01/aio/operations/__init__.py new file mode 100644 index 000000000000..47d8f29e4b2c --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_09_01/aio/operations/__init__.py @@ -0,0 +1,22 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._application_client_operations import ApplicationClientOperationsMixin +from ._applications_operations import ApplicationsOperations +from ._application_definitions_operations import ApplicationDefinitionsOperations + +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk +__all__ = [ + 'ApplicationClientOperationsMixin', + 'ApplicationsOperations', + 'ApplicationDefinitionsOperations', +] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_09_01/aio/operations/_application_client_operations.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_09_01/aio/operations/_application_client_operations.py new file mode 100644 index 000000000000..d6fa98bf5255 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_09_01/aio/operations/_application_client_operations.py @@ -0,0 +1,105 @@ +# 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.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._application_client_operations import build_list_operations_request +from .._vendor import MixinABC +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class ApplicationClientOperationsMixin(MixinABC): + + @distributed_trace + def list_operations( + self, + **kwargs: Any + ) -> AsyncIterable[_models.OperationListResult]: + """Lists all of the available Microsoft.Solutions REST API operations. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either OperationListResult or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.managedapplication.v2017_09_01.models.OperationListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-09-01")) # 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', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_operations_request( + api_version=api_version, + template_url=self.list_operations.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_operations_request( + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list_operations.metadata = {'url': "/providers/Microsoft.Solutions/operations"} # type: ignore diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_09_01/aio/operations/_application_definitions_operations.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_09_01/aio/operations/_application_definitions_operations.py new file mode 100644 index 000000000000..dfcdf54b7906 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_09_01/aio/operations/_application_definitions_operations.py @@ -0,0 +1,487 @@ +# 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.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._application_definitions_operations import build_create_or_update_request, build_delete_request, build_get_request, build_list_by_resource_group_request, build_list_by_subscription_request, build_update_request +from .._vendor import MixinABC +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class ApplicationDefinitionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.managedapplication.v2017_09_01.aio.ApplicationClient`'s + :attr:`application_definitions` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + application_definition_name: str, + **kwargs: Any + ) -> Optional[_models.ApplicationDefinition]: + """Gets the managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. + :type application_definition_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ApplicationDefinition, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2017_09_01.models.ApplicationDefinition or None + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-09-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.ApplicationDefinition]] + + + request = build_get_request( + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('ApplicationDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore + + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + application_definition_name: str, + **kwargs: Any + ) -> None: + """Deletes the managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition to delete. + :type application_definition_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-09-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_request( + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore + + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + application_definition_name: str, + parameters: _models.ApplicationDefinition, + **kwargs: Any + ) -> _models.ApplicationDefinition: + """Creates or updates a managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. + :type application_definition_name: str + :param parameters: Parameters supplied to the create or update an managed application + definition. + :type parameters: ~azure.mgmt.managedapplication.v2017_09_01.models.ApplicationDefinition + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ApplicationDefinition, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2017_09_01.models.ApplicationDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-09-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationDefinition] + + _json = self._serialize.body(parameters, 'ApplicationDefinition') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # 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, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('ApplicationDefinition', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('ApplicationDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore + + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + application_definition_name: str, + parameters: _models.ApplicationDefinitionPatchable, + **kwargs: Any + ) -> _models.ApplicationDefinition: + """Updates the managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition to delete. + :type application_definition_name: str + :param parameters: Parameters supplied to the update a managed application definition. + :type parameters: + ~azure.mgmt.managedapplication.v2017_09_01.models.ApplicationDefinitionPatchable + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ApplicationDefinition, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2017_09_01.models.ApplicationDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-09-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationDefinition] + + _json = self._serialize.body(parameters, 'ApplicationDefinitionPatchable') + + request = build_update_request( + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ApplicationDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore + + + @distributed_trace + def list_by_resource_group( + self, + resource_group_name: str, + **kwargs: Any + ) -> AsyncIterable[_models.ApplicationDefinitionListResult]: + """Lists the managed application definitions in a resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ApplicationDefinitionListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.managedapplication.v2017_09_01.models.ApplicationDefinitionListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-09-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationDefinitionListResult] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_resource_group.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ApplicationDefinitionListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions"} # type: ignore + + @distributed_trace + def list_by_subscription( + self, + **kwargs: Any + ) -> AsyncIterable[_models.ApplicationDefinitionListResult]: + """Lists the managed application definitions in a subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ApplicationDefinitionListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.managedapplication.v2017_09_01.models.ApplicationDefinitionListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-09-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationDefinitionListResult] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ApplicationDefinitionListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Solutions/applicationDefinitions"} # type: ignore diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_09_01/aio/operations/_applications_operations.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_09_01/aio/operations/_applications_operations.py new file mode 100644 index 000000000000..48a0ad5d6a73 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_09_01/aio/operations/_applications_operations.py @@ -0,0 +1,1149 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union, cast + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._applications_operations import build_create_or_update_by_id_request_initial, build_create_or_update_request_initial, build_delete_by_id_request_initial, build_delete_request_initial, build_get_by_id_request, build_get_request, build_list_by_resource_group_request, build_list_by_subscription_request, build_update_by_id_request_initial, build_update_request_initial +from .._vendor import MixinABC +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class ApplicationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.managedapplication.v2017_09_01.aio.ApplicationClient`'s + :attr:`applications` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + application_name: str, + **kwargs: Any + ) -> Optional[_models.Application]: + """Gets the managed application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_name: The name of the managed application. + :type application_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Application, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2017_09_01.models.Application or None + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-09-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.Application]] + + + request = build_get_request( + resource_group_name=resource_group_name, + application_name=application_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('Application', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}"} # type: ignore + + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + application_name: str, + **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-09-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + application_name=application_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}"} # type: ignore + + + @distributed_trace_async + async def begin_delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + application_name: str, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes the managed application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_name: The name of the managed application. + :type application_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-09-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._delete_initial( # type: ignore + resource_group_name=resource_group_name, + application_name=application_name, + api_version=api_version, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}"} # type: ignore + + async def _create_or_update_initial( + self, + resource_group_name: str, + application_name: str, + parameters: _models.Application, + **kwargs: Any + ) -> _models.Application: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-09-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Application] + + _json = self._serialize.body(parameters, 'Application') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + application_name=application_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('Application', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('Application', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}"} # type: ignore + + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + application_name: str, + parameters: _models.Application, + **kwargs: Any + ) -> AsyncLROPoller[_models.Application]: + """Creates or updates a managed application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_name: The name of the managed application. + :type application_name: str + :param parameters: Parameters supplied to the create or update a managed application. + :type parameters: ~azure.mgmt.managedapplication.v2017_09_01.models.Application + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either Application or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.managedapplication.v2017_09_01.models.Application] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-09-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Application] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._create_or_update_initial( # type: ignore + resource_group_name=resource_group_name, + application_name=application_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('Application', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}"} # type: ignore + + async def _update_initial( + self, + resource_group_name: str, + application_name: str, + parameters: Optional[_models.ApplicationPatchable] = None, + **kwargs: Any + ) -> _models.ApplicationPatchable: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-09-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationPatchable] + + if parameters is not None: + _json = self._serialize.body(parameters, 'ApplicationPatchable') + else: + _json = None + + request = build_update_request_initial( + resource_group_name=resource_group_name, + application_name=application_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('ApplicationPatchable', pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize('ApplicationPatchable', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}"} # type: ignore + + + @distributed_trace_async + async def begin_update( + self, + resource_group_name: str, + application_name: str, + parameters: Optional[_models.ApplicationPatchable] = None, + **kwargs: Any + ) -> AsyncLROPoller[_models.ApplicationPatchable]: + """Updates an existing managed application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_name: The name of the managed application. + :type application_name: str + :param parameters: Parameters supplied to update an existing managed application. Default value + is None. + :type parameters: ~azure.mgmt.managedapplication.v2017_09_01.models.ApplicationPatchable + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ApplicationPatchable or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.managedapplication.v2017_09_01.models.ApplicationPatchable] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-09-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationPatchable] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._update_initial( # type: ignore + resource_group_name=resource_group_name, + application_name=application_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('ApplicationPatchable', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}"} # type: ignore + + @distributed_trace + def list_by_resource_group( + self, + resource_group_name: str, + **kwargs: Any + ) -> AsyncIterable[_models.ApplicationListResult]: + """Lists all the applications within a resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ApplicationListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.managedapplication.v2017_09_01.models.ApplicationListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-09-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationListResult] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_resource_group.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ApplicationListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications"} # type: ignore + + @distributed_trace + def list_by_subscription( + self, + **kwargs: Any + ) -> AsyncIterable[_models.ApplicationListResult]: + """Lists all the applications within a subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ApplicationListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.managedapplication.v2017_09_01.models.ApplicationListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-09-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationListResult] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ApplicationListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Solutions/applications"} # type: ignore + + @distributed_trace_async + async def get_by_id( + self, + application_id: str, + **kwargs: Any + ) -> Optional[_models.Application]: + """Gets the managed application. + + :param application_id: The fully qualified ID of the managed application, including the managed + application name and the managed application resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/Microsoft.Solutions/applications/{application-name}. + :type application_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Application, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2017_09_01.models.Application or None + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-09-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.Application]] + + + request = build_get_by_id_request( + application_id=application_id, + api_version=api_version, + template_url=self.get_by_id.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('Application', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_by_id.metadata = {'url': "/{applicationId}"} # type: ignore + + + async def _delete_by_id_initial( # pylint: disable=inconsistent-return-statements + self, + application_id: str, + **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-09-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_by_id_request_initial( + application_id=application_id, + api_version=api_version, + template_url=self._delete_by_id_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_by_id_initial.metadata = {'url': "/{applicationId}"} # type: ignore + + + @distributed_trace_async + async def begin_delete_by_id( # pylint: disable=inconsistent-return-statements + self, + application_id: str, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes the managed application. + + :param application_id: The fully qualified ID of the managed application, including the managed + application name and the managed application resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/Microsoft.Solutions/applications/{application-name}. + :type application_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-09-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._delete_by_id_initial( # type: ignore + application_id=application_id, + api_version=api_version, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete_by_id.metadata = {'url': "/{applicationId}"} # type: ignore + + async def _create_or_update_by_id_initial( + self, + application_id: str, + parameters: _models.Application, + **kwargs: Any + ) -> _models.Application: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-09-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Application] + + _json = self._serialize.body(parameters, 'Application') + + request = build_create_or_update_by_id_request_initial( + application_id=application_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._create_or_update_by_id_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('Application', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('Application', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_by_id_initial.metadata = {'url': "/{applicationId}"} # type: ignore + + + @distributed_trace_async + async def begin_create_or_update_by_id( + self, + application_id: str, + parameters: _models.Application, + **kwargs: Any + ) -> AsyncLROPoller[_models.Application]: + """Creates or updates a managed application. + + :param application_id: The fully qualified ID of the managed application, including the managed + application name and the managed application resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/Microsoft.Solutions/applications/{application-name}. + :type application_id: str + :param parameters: Parameters supplied to the create or update a managed application. + :type parameters: ~azure.mgmt.managedapplication.v2017_09_01.models.Application + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either Application or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.managedapplication.v2017_09_01.models.Application] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-09-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Application] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._create_or_update_by_id_initial( # type: ignore + application_id=application_id, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('Application', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update_by_id.metadata = {'url': "/{applicationId}"} # type: ignore + + async def _update_by_id_initial( + self, + application_id: str, + parameters: Optional[_models.ApplicationPatchable] = None, + **kwargs: Any + ) -> _models.ApplicationPatchable: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-09-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationPatchable] + + if parameters is not None: + _json = self._serialize.body(parameters, 'ApplicationPatchable') + else: + _json = None + + request = build_update_by_id_request_initial( + application_id=application_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._update_by_id_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('ApplicationPatchable', pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize('ApplicationPatchable', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _update_by_id_initial.metadata = {'url': "/{applicationId}"} # type: ignore + + + @distributed_trace_async + async def begin_update_by_id( + self, + application_id: str, + parameters: Optional[_models.ApplicationPatchable] = None, + **kwargs: Any + ) -> AsyncLROPoller[_models.ApplicationPatchable]: + """Updates an existing managed application. + + :param application_id: The fully qualified ID of the managed application, including the managed + application name and the managed application resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/Microsoft.Solutions/applications/{application-name}. + :type application_id: str + :param parameters: Parameters supplied to update an existing managed application. Default value + is None. + :type parameters: ~azure.mgmt.managedapplication.v2017_09_01.models.ApplicationPatchable + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ApplicationPatchable or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.managedapplication.v2017_09_01.models.ApplicationPatchable] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-09-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationPatchable] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._update_by_id_initial( # type: ignore + application_id=application_id, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('ApplicationPatchable', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_update_by_id.metadata = {'url': "/{applicationId}"} # type: ignore diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_09_01/aio/operations/_patch.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_09_01/aio/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_09_01/aio/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_09_01/models/__init__.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_09_01/models/__init__.py new file mode 100644 index 000000000000..769407b4688b --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_09_01/models/__init__.py @@ -0,0 +1,69 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._models_py3 import Application +from ._models_py3 import ApplicationArtifact +from ._models_py3 import ApplicationDefinition +from ._models_py3 import ApplicationDefinitionListResult +from ._models_py3 import ApplicationDefinitionPatchable +from ._models_py3 import ApplicationListResult +from ._models_py3 import ApplicationPatchable +from ._models_py3 import ApplicationProviderAuthorization +from ._models_py3 import ErrorAdditionalInfo +from ._models_py3 import ErrorDetail +from ._models_py3 import ErrorResponse +from ._models_py3 import GenericResource +from ._models_py3 import Identity +from ._models_py3 import Operation +from ._models_py3 import OperationDisplay +from ._models_py3 import OperationListResult +from ._models_py3 import Plan +from ._models_py3 import PlanPatchable +from ._models_py3 import Resource +from ._models_py3 import Sku + + +from ._application_client_enums import ( + ActionType, + ApplicationArtifactType, + ApplicationLockLevel, + Origin, + ProvisioningState, +) +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk +__all__ = [ + 'Application', + 'ApplicationArtifact', + 'ApplicationDefinition', + 'ApplicationDefinitionListResult', + 'ApplicationDefinitionPatchable', + 'ApplicationListResult', + 'ApplicationPatchable', + 'ApplicationProviderAuthorization', + 'ErrorAdditionalInfo', + 'ErrorDetail', + 'ErrorResponse', + 'GenericResource', + 'Identity', + 'Operation', + 'OperationDisplay', + 'OperationListResult', + 'Plan', + 'PlanPatchable', + 'Resource', + 'Sku', + 'ActionType', + 'ApplicationArtifactType', + 'ApplicationLockLevel', + 'Origin', + 'ProvisioningState', +] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_09_01/models/_application_client_enums.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_09_01/models/_application_client_enums.py new file mode 100644 index 000000000000..4cdef06e66d1 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_09_01/models/_application_client_enums.py @@ -0,0 +1,57 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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 azure.core import CaseInsensitiveEnumMeta + + +class ActionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. + """ + + INTERNAL = "Internal" + +class ApplicationArtifactType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The managed application artifact type. + """ + + TEMPLATE = "Template" + CUSTOM = "Custom" + +class ApplicationLockLevel(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The managed application lock level. + """ + + CAN_NOT_DELETE = "CanNotDelete" + READ_ONLY = "ReadOnly" + NONE = "None" + +class Origin(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit + logs UX. Default value is "user,system" + """ + + USER = "user" + SYSTEM = "system" + USER_SYSTEM = "user,system" + +class ProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Provisioning status of the managed application. + """ + + ACCEPTED = "Accepted" + RUNNING = "Running" + READY = "Ready" + CREATING = "Creating" + CREATED = "Created" + DELETING = "Deleting" + DELETED = "Deleted" + CANCELED = "Canceled" + FAILED = "Failed" + SUCCEEDED = "Succeeded" + UPDATING = "Updating" diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_09_01/models/_models_py3.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_09_01/models/_models_py3.py new file mode 100644 index 000000000000..3403a891ad87 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_09_01/models/_models_py3.py @@ -0,0 +1,1175 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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, Dict, List, Optional, TYPE_CHECKING, Union + +from azure.core.exceptions import HttpResponseError +import msrest.serialization + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + import __init__ as _models + + +class Resource(msrest.serialization.Model): + """Resource information. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Resource ID. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar location: Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'location': {'key': 'location', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + } + + def __init__( + self, + *, + location: Optional[str] = None, + tags: Optional[Dict[str, str]] = None, + **kwargs + ): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + """ + super(Resource, self).__init__(**kwargs) + self.id = None + self.name = None + self.type = None + self.location = location + self.tags = tags + + +class GenericResource(Resource): + """Resource information. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Resource ID. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar location: Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar managed_by: ID of the resource that manages this resource. + :vartype managed_by: str + :ivar sku: The SKU of the resource. + :vartype sku: ~azure.mgmt.managedapplication.v2017_09_01.models.Sku + :ivar identity: The identity of the resource. + :vartype identity: ~azure.mgmt.managedapplication.v2017_09_01.models.Identity + """ + + _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'}, + 'location': {'key': 'location', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + 'managed_by': {'key': 'managedBy', 'type': 'str'}, + 'sku': {'key': 'sku', 'type': 'Sku'}, + 'identity': {'key': 'identity', 'type': 'Identity'}, + } + + def __init__( + self, + *, + location: Optional[str] = None, + tags: Optional[Dict[str, str]] = None, + managed_by: Optional[str] = None, + sku: Optional["_models.Sku"] = None, + identity: Optional["_models.Identity"] = None, + **kwargs + ): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword managed_by: ID of the resource that manages this resource. + :paramtype managed_by: str + :keyword sku: The SKU of the resource. + :paramtype sku: ~azure.mgmt.managedapplication.v2017_09_01.models.Sku + :keyword identity: The identity of the resource. + :paramtype identity: ~azure.mgmt.managedapplication.v2017_09_01.models.Identity + """ + super(GenericResource, self).__init__(location=location, tags=tags, **kwargs) + self.managed_by = managed_by + self.sku = sku + self.identity = identity + + +class Application(GenericResource): + """Information about managed application. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar id: Resource ID. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar location: Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar managed_by: ID of the resource that manages this resource. + :vartype managed_by: str + :ivar sku: The SKU of the resource. + :vartype sku: ~azure.mgmt.managedapplication.v2017_09_01.models.Sku + :ivar identity: The identity of the resource. + :vartype identity: ~azure.mgmt.managedapplication.v2017_09_01.models.Identity + :ivar plan: The plan information. + :vartype plan: ~azure.mgmt.managedapplication.v2017_09_01.models.Plan + :ivar kind: Required. The kind of the managed application. Allowed values are MarketPlace and + ServiceCatalog. + :vartype kind: str + :ivar managed_resource_group_id: Required. The managed resource group Id. + :vartype managed_resource_group_id: str + :ivar application_definition_id: The fully qualified path of managed application definition Id. + :vartype application_definition_id: str + :ivar parameters: Name and value pairs that define the managed application parameters. It can + be a JObject or a well formed JSON string. + :vartype parameters: any + :ivar outputs: Name and value pairs that define the managed application outputs. + :vartype outputs: any + :ivar provisioning_state: The managed application provisioning state. Known values are: + "Accepted", "Running", "Ready", "Creating", "Created", "Deleting", "Deleted", "Canceled", + "Failed", "Succeeded", "Updating". + :vartype provisioning_state: str or + ~azure.mgmt.managedapplication.v2017_09_01.models.ProvisioningState + :ivar ui_definition_uri: The blob URI where the UI definition file is located. + :vartype ui_definition_uri: str + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'kind': {'required': True, 'pattern': r'^[-\w\._,\(\)]+$'}, + 'managed_resource_group_id': {'required': True}, + 'outputs': {'readonly': True}, + 'provisioning_state': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'location': {'key': 'location', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + 'managed_by': {'key': 'managedBy', 'type': 'str'}, + 'sku': {'key': 'sku', 'type': 'Sku'}, + 'identity': {'key': 'identity', 'type': 'Identity'}, + 'plan': {'key': 'plan', 'type': 'Plan'}, + 'kind': {'key': 'kind', 'type': 'str'}, + 'managed_resource_group_id': {'key': 'properties.managedResourceGroupId', 'type': 'str'}, + 'application_definition_id': {'key': 'properties.applicationDefinitionId', 'type': 'str'}, + 'parameters': {'key': 'properties.parameters', 'type': 'object'}, + 'outputs': {'key': 'properties.outputs', 'type': 'object'}, + 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + 'ui_definition_uri': {'key': 'properties.uiDefinitionUri', 'type': 'str'}, + } + + def __init__( + self, + *, + kind: str, + managed_resource_group_id: str, + location: Optional[str] = None, + tags: Optional[Dict[str, str]] = None, + managed_by: Optional[str] = None, + sku: Optional["_models.Sku"] = None, + identity: Optional["_models.Identity"] = None, + plan: Optional["_models.Plan"] = None, + application_definition_id: Optional[str] = None, + parameters: Optional[Any] = None, + ui_definition_uri: Optional[str] = None, + **kwargs + ): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword managed_by: ID of the resource that manages this resource. + :paramtype managed_by: str + :keyword sku: The SKU of the resource. + :paramtype sku: ~azure.mgmt.managedapplication.v2017_09_01.models.Sku + :keyword identity: The identity of the resource. + :paramtype identity: ~azure.mgmt.managedapplication.v2017_09_01.models.Identity + :keyword plan: The plan information. + :paramtype plan: ~azure.mgmt.managedapplication.v2017_09_01.models.Plan + :keyword kind: Required. The kind of the managed application. Allowed values are MarketPlace + and ServiceCatalog. + :paramtype kind: str + :keyword managed_resource_group_id: Required. The managed resource group Id. + :paramtype managed_resource_group_id: str + :keyword application_definition_id: The fully qualified path of managed application definition + Id. + :paramtype application_definition_id: str + :keyword parameters: Name and value pairs that define the managed application parameters. It + can be a JObject or a well formed JSON string. + :paramtype parameters: any + :keyword ui_definition_uri: The blob URI where the UI definition file is located. + :paramtype ui_definition_uri: str + """ + super(Application, self).__init__(location=location, tags=tags, managed_by=managed_by, sku=sku, identity=identity, **kwargs) + self.plan = plan + self.kind = kind + self.managed_resource_group_id = managed_resource_group_id + self.application_definition_id = application_definition_id + self.parameters = parameters + self.outputs = None + self.provisioning_state = None + self.ui_definition_uri = ui_definition_uri + + +class ApplicationArtifact(msrest.serialization.Model): + """Managed application artifact. + + :ivar name: The managed application artifact name. + :vartype name: str + :ivar uri: The managed application artifact blob uri. + :vartype uri: str + :ivar type: The managed application artifact type. Known values are: "Template", "Custom". + :vartype type: str or ~azure.mgmt.managedapplication.v2017_09_01.models.ApplicationArtifactType + """ + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'uri': {'key': 'uri', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + uri: Optional[str] = None, + type: Optional[Union[str, "_models.ApplicationArtifactType"]] = None, + **kwargs + ): + """ + :keyword name: The managed application artifact name. + :paramtype name: str + :keyword uri: The managed application artifact blob uri. + :paramtype uri: str + :keyword type: The managed application artifact type. Known values are: "Template", "Custom". + :paramtype type: str or + ~azure.mgmt.managedapplication.v2017_09_01.models.ApplicationArtifactType + """ + super(ApplicationArtifact, self).__init__(**kwargs) + self.name = name + self.uri = uri + self.type = type + + +class ApplicationDefinition(GenericResource): + """Information about managed application definition. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar id: Resource ID. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar location: Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar managed_by: ID of the resource that manages this resource. + :vartype managed_by: str + :ivar sku: The SKU of the resource. + :vartype sku: ~azure.mgmt.managedapplication.v2017_09_01.models.Sku + :ivar identity: The identity of the resource. + :vartype identity: ~azure.mgmt.managedapplication.v2017_09_01.models.Identity + :ivar lock_level: Required. The managed application lock level. Known values are: + "CanNotDelete", "ReadOnly", "None". + :vartype lock_level: str or + ~azure.mgmt.managedapplication.v2017_09_01.models.ApplicationLockLevel + :ivar display_name: The managed application definition display name. + :vartype display_name: str + :ivar is_enabled: A value indicating whether the package is enabled or not. + :vartype is_enabled: str + :ivar authorizations: Required. The managed application provider authorizations. + :vartype authorizations: + list[~azure.mgmt.managedapplication.v2017_09_01.models.ApplicationProviderAuthorization] + :ivar artifacts: The collection of managed application artifacts. The portal will use the files + specified as artifacts to construct the user experience of creating a managed application from + a managed application definition. + :vartype artifacts: list[~azure.mgmt.managedapplication.v2017_09_01.models.ApplicationArtifact] + :ivar description: The managed application definition description. + :vartype description: str + :ivar package_file_uri: The managed application definition package file Uri. Use this element. + :vartype package_file_uri: str + :ivar main_template: The inline main template json which has resources to be provisioned. It + can be a JObject or well-formed JSON string. + :vartype main_template: any + :ivar create_ui_definition: The createUiDefinition json for the backing template with + Microsoft.Solutions/applications resource. It can be a JObject or well-formed JSON string. + :vartype create_ui_definition: any + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'lock_level': {'required': True}, + 'authorizations': {'required': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'location': {'key': 'location', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + 'managed_by': {'key': 'managedBy', 'type': 'str'}, + 'sku': {'key': 'sku', 'type': 'Sku'}, + 'identity': {'key': 'identity', 'type': 'Identity'}, + 'lock_level': {'key': 'properties.lockLevel', 'type': 'str'}, + 'display_name': {'key': 'properties.displayName', 'type': 'str'}, + 'is_enabled': {'key': 'properties.isEnabled', 'type': 'str'}, + 'authorizations': {'key': 'properties.authorizations', 'type': '[ApplicationProviderAuthorization]'}, + 'artifacts': {'key': 'properties.artifacts', 'type': '[ApplicationArtifact]'}, + 'description': {'key': 'properties.description', 'type': 'str'}, + 'package_file_uri': {'key': 'properties.packageFileUri', 'type': 'str'}, + 'main_template': {'key': 'properties.mainTemplate', 'type': 'object'}, + 'create_ui_definition': {'key': 'properties.createUiDefinition', 'type': 'object'}, + } + + def __init__( + self, + *, + lock_level: Union[str, "_models.ApplicationLockLevel"], + authorizations: List["_models.ApplicationProviderAuthorization"], + location: Optional[str] = None, + tags: Optional[Dict[str, str]] = None, + managed_by: Optional[str] = None, + sku: Optional["_models.Sku"] = None, + identity: Optional["_models.Identity"] = None, + display_name: Optional[str] = None, + is_enabled: Optional[str] = None, + artifacts: Optional[List["_models.ApplicationArtifact"]] = None, + description: Optional[str] = None, + package_file_uri: Optional[str] = None, + main_template: Optional[Any] = None, + create_ui_definition: Optional[Any] = None, + **kwargs + ): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword managed_by: ID of the resource that manages this resource. + :paramtype managed_by: str + :keyword sku: The SKU of the resource. + :paramtype sku: ~azure.mgmt.managedapplication.v2017_09_01.models.Sku + :keyword identity: The identity of the resource. + :paramtype identity: ~azure.mgmt.managedapplication.v2017_09_01.models.Identity + :keyword lock_level: Required. The managed application lock level. Known values are: + "CanNotDelete", "ReadOnly", "None". + :paramtype lock_level: str or + ~azure.mgmt.managedapplication.v2017_09_01.models.ApplicationLockLevel + :keyword display_name: The managed application definition display name. + :paramtype display_name: str + :keyword is_enabled: A value indicating whether the package is enabled or not. + :paramtype is_enabled: str + :keyword authorizations: Required. The managed application provider authorizations. + :paramtype authorizations: + list[~azure.mgmt.managedapplication.v2017_09_01.models.ApplicationProviderAuthorization] + :keyword artifacts: The collection of managed application artifacts. The portal will use the + files specified as artifacts to construct the user experience of creating a managed application + from a managed application definition. + :paramtype artifacts: + list[~azure.mgmt.managedapplication.v2017_09_01.models.ApplicationArtifact] + :keyword description: The managed application definition description. + :paramtype description: str + :keyword package_file_uri: The managed application definition package file Uri. Use this + element. + :paramtype package_file_uri: str + :keyword main_template: The inline main template json which has resources to be provisioned. It + can be a JObject or well-formed JSON string. + :paramtype main_template: any + :keyword create_ui_definition: The createUiDefinition json for the backing template with + Microsoft.Solutions/applications resource. It can be a JObject or well-formed JSON string. + :paramtype create_ui_definition: any + """ + super(ApplicationDefinition, self).__init__(location=location, tags=tags, managed_by=managed_by, sku=sku, identity=identity, **kwargs) + self.lock_level = lock_level + self.display_name = display_name + self.is_enabled = is_enabled + self.authorizations = authorizations + self.artifacts = artifacts + self.description = description + self.package_file_uri = package_file_uri + self.main_template = main_template + self.create_ui_definition = create_ui_definition + + +class ApplicationDefinitionListResult(msrest.serialization.Model): + """List of managed application definitions. + + :ivar value: The array of managed application definitions. + :vartype value: list[~azure.mgmt.managedapplication.v2017_09_01.models.ApplicationDefinition] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[ApplicationDefinition]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["_models.ApplicationDefinition"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + """ + :keyword value: The array of managed application definitions. + :paramtype value: list[~azure.mgmt.managedapplication.v2017_09_01.models.ApplicationDefinition] + :keyword next_link: The URL to use for getting the next set of results. + :paramtype next_link: str + """ + super(ApplicationDefinitionListResult, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class ApplicationDefinitionPatchable(msrest.serialization.Model): + """Information about an application definition request. + + :ivar tags: A set of tags. Application definition tags. + :vartype tags: dict[str, str] + """ + + _attribute_map = { + 'tags': {'key': 'tags', 'type': '{str}'}, + } + + def __init__( + self, + *, + tags: Optional[Dict[str, str]] = None, + **kwargs + ): + """ + :keyword tags: A set of tags. Application definition tags. + :paramtype tags: dict[str, str] + """ + super(ApplicationDefinitionPatchable, self).__init__(**kwargs) + self.tags = tags + + +class ApplicationListResult(msrest.serialization.Model): + """List of managed applications. + + :ivar value: The array of managed applications. + :vartype value: list[~azure.mgmt.managedapplication.v2017_09_01.models.Application] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Application]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["_models.Application"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + """ + :keyword value: The array of managed applications. + :paramtype value: list[~azure.mgmt.managedapplication.v2017_09_01.models.Application] + :keyword next_link: The URL to use for getting the next set of results. + :paramtype next_link: str + """ + super(ApplicationListResult, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class ApplicationPatchable(GenericResource): + """Information about managed application. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Resource ID. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar location: Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar managed_by: ID of the resource that manages this resource. + :vartype managed_by: str + :ivar sku: The SKU of the resource. + :vartype sku: ~azure.mgmt.managedapplication.v2017_09_01.models.Sku + :ivar identity: The identity of the resource. + :vartype identity: ~azure.mgmt.managedapplication.v2017_09_01.models.Identity + :ivar plan: The plan information. + :vartype plan: ~azure.mgmt.managedapplication.v2017_09_01.models.PlanPatchable + :ivar kind: The kind of the managed application. Allowed values are MarketPlace and + ServiceCatalog. + :vartype kind: str + :ivar managed_resource_group_id: The managed resource group Id. + :vartype managed_resource_group_id: str + :ivar application_definition_id: The fully qualified path of managed application definition Id. + :vartype application_definition_id: str + :ivar parameters: Name and value pairs that define the managed application parameters. It can + be a JObject or a well formed JSON string. + :vartype parameters: any + :ivar outputs: Name and value pairs that define the managed application outputs. + :vartype outputs: any + :ivar provisioning_state: The managed application provisioning state. Known values are: + "Accepted", "Running", "Ready", "Creating", "Created", "Deleting", "Deleted", "Canceled", + "Failed", "Succeeded", "Updating". + :vartype provisioning_state: str or + ~azure.mgmt.managedapplication.v2017_09_01.models.ProvisioningState + :ivar ui_definition_uri: The blob URI where the UI definition file is located. + :vartype ui_definition_uri: str + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'kind': {'pattern': r'^[-\w\._,\(\)]+$'}, + 'outputs': {'readonly': True}, + 'provisioning_state': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'location': {'key': 'location', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + 'managed_by': {'key': 'managedBy', 'type': 'str'}, + 'sku': {'key': 'sku', 'type': 'Sku'}, + 'identity': {'key': 'identity', 'type': 'Identity'}, + 'plan': {'key': 'plan', 'type': 'PlanPatchable'}, + 'kind': {'key': 'kind', 'type': 'str'}, + 'managed_resource_group_id': {'key': 'properties.managedResourceGroupId', 'type': 'str'}, + 'application_definition_id': {'key': 'properties.applicationDefinitionId', 'type': 'str'}, + 'parameters': {'key': 'properties.parameters', 'type': 'object'}, + 'outputs': {'key': 'properties.outputs', 'type': 'object'}, + 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + 'ui_definition_uri': {'key': 'properties.uiDefinitionUri', 'type': 'str'}, + } + + def __init__( + self, + *, + location: Optional[str] = None, + tags: Optional[Dict[str, str]] = None, + managed_by: Optional[str] = None, + sku: Optional["_models.Sku"] = None, + identity: Optional["_models.Identity"] = None, + plan: Optional["_models.PlanPatchable"] = None, + kind: Optional[str] = None, + managed_resource_group_id: Optional[str] = None, + application_definition_id: Optional[str] = None, + parameters: Optional[Any] = None, + ui_definition_uri: Optional[str] = None, + **kwargs + ): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword managed_by: ID of the resource that manages this resource. + :paramtype managed_by: str + :keyword sku: The SKU of the resource. + :paramtype sku: ~azure.mgmt.managedapplication.v2017_09_01.models.Sku + :keyword identity: The identity of the resource. + :paramtype identity: ~azure.mgmt.managedapplication.v2017_09_01.models.Identity + :keyword plan: The plan information. + :paramtype plan: ~azure.mgmt.managedapplication.v2017_09_01.models.PlanPatchable + :keyword kind: The kind of the managed application. Allowed values are MarketPlace and + ServiceCatalog. + :paramtype kind: str + :keyword managed_resource_group_id: The managed resource group Id. + :paramtype managed_resource_group_id: str + :keyword application_definition_id: The fully qualified path of managed application definition + Id. + :paramtype application_definition_id: str + :keyword parameters: Name and value pairs that define the managed application parameters. It + can be a JObject or a well formed JSON string. + :paramtype parameters: any + :keyword ui_definition_uri: The blob URI where the UI definition file is located. + :paramtype ui_definition_uri: str + """ + super(ApplicationPatchable, self).__init__(location=location, tags=tags, managed_by=managed_by, sku=sku, identity=identity, **kwargs) + self.plan = plan + self.kind = kind + self.managed_resource_group_id = managed_resource_group_id + self.application_definition_id = application_definition_id + self.parameters = parameters + self.outputs = None + self.provisioning_state = None + self.ui_definition_uri = ui_definition_uri + + +class ApplicationProviderAuthorization(msrest.serialization.Model): + """The managed application provider authorization. + + All required parameters must be populated in order to send to Azure. + + :ivar principal_id: Required. The provider's principal identifier. This is the identity that + the provider will use to call ARM to manage the managed application resources. + :vartype principal_id: str + :ivar role_definition_id: Required. The provider's role definition identifier. This role will + define all the permissions that the provider must have on the managed application's container + resource group. This role definition cannot have permission to delete the resource group. + :vartype role_definition_id: str + """ + + _validation = { + 'principal_id': {'required': True}, + 'role_definition_id': {'required': True}, + } + + _attribute_map = { + 'principal_id': {'key': 'principalId', 'type': 'str'}, + 'role_definition_id': {'key': 'roleDefinitionId', 'type': 'str'}, + } + + def __init__( + self, + *, + principal_id: str, + role_definition_id: str, + **kwargs + ): + """ + :keyword principal_id: Required. The provider's principal identifier. This is the identity that + the provider will use to call ARM to manage the managed application resources. + :paramtype principal_id: str + :keyword role_definition_id: Required. The provider's role definition identifier. This role + will define all the permissions that the provider must have on the managed application's + container resource group. This role definition cannot have permission to delete the resource + group. + :paramtype role_definition_id: str + """ + super(ApplicationProviderAuthorization, self).__init__(**kwargs) + self.principal_id = principal_id + self.role_definition_id = role_definition_id + + +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.managedapplication.v2017_09_01.models.ErrorDetail] + :ivar additional_info: The error additional info. + :vartype additional_info: + list[~azure.mgmt.managedapplication.v2017_09_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.). + + :ivar error: The error object. + :vartype error: ~azure.mgmt.managedapplication.v2017_09_01.models.ErrorDetail + """ + + _attribute_map = { + 'error': {'key': 'error', 'type': 'ErrorDetail'}, + } + + def __init__( + self, + *, + error: Optional["_models.ErrorDetail"] = None, + **kwargs + ): + """ + :keyword error: The error object. + :paramtype error: ~azure.mgmt.managedapplication.v2017_09_01.models.ErrorDetail + """ + super(ErrorResponse, self).__init__(**kwargs) + self.error = error + + +class Identity(msrest.serialization.Model): + """Identity for the resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar principal_id: The principal ID of resource identity. + :vartype principal_id: str + :ivar tenant_id: The tenant ID of resource. + :vartype tenant_id: str + :ivar type: The identity type. The only acceptable values to pass in are None and + "SystemAssigned". The default value is None. + :vartype type: str + """ + + _validation = { + 'principal_id': {'readonly': True}, + 'tenant_id': {'readonly': True}, + } + + _attribute_map = { + 'principal_id': {'key': 'principalId', 'type': 'str'}, + 'tenant_id': {'key': 'tenantId', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + } + + def __init__( + self, + *, + type: Optional[str] = None, + **kwargs + ): + """ + :keyword type: The identity type. The only acceptable values to pass in are None and + "SystemAssigned". The default value is None. + :paramtype type: str + """ + super(Identity, self).__init__(**kwargs) + self.principal_id = None + self.tenant_id = None + self.type = type + + +class Operation(msrest.serialization.Model): + """Details of a REST API operation, returned from the Resource Provider Operations API. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name: The name of the operation, as per Resource-Based Access Control (RBAC). Examples: + "Microsoft.Compute/virtualMachines/write", "Microsoft.Compute/virtualMachines/capture/action". + :vartype name: str + :ivar is_data_action: Whether the operation applies to data-plane. This is "true" for + data-plane operations and "false" for ARM/control-plane operations. + :vartype is_data_action: bool + :ivar display: Localized display information for this particular operation. + :vartype display: ~azure.mgmt.managedapplication.v2017_09_01.models.OperationDisplay + :ivar origin: The intended executor of the operation; as in Resource Based Access Control + (RBAC) and audit logs UX. Default value is "user,system". Known values are: "user", "system", + "user,system". + :vartype origin: str or ~azure.mgmt.managedapplication.v2017_09_01.models.Origin + :ivar action_type: Enum. Indicates the action type. "Internal" refers to actions that are for + internal only APIs. Known values are: "Internal". + :vartype action_type: str or ~azure.mgmt.managedapplication.v2017_09_01.models.ActionType + """ + + _validation = { + 'name': {'readonly': True}, + 'is_data_action': {'readonly': True}, + 'origin': {'readonly': True}, + 'action_type': {'readonly': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'is_data_action': {'key': 'isDataAction', 'type': 'bool'}, + 'display': {'key': 'display', 'type': 'OperationDisplay'}, + 'origin': {'key': 'origin', 'type': 'str'}, + 'action_type': {'key': 'actionType', 'type': 'str'}, + } + + def __init__( + self, + *, + display: Optional["_models.OperationDisplay"] = None, + **kwargs + ): + """ + :keyword display: Localized display information for this particular operation. + :paramtype display: ~azure.mgmt.managedapplication.v2017_09_01.models.OperationDisplay + """ + super(Operation, self).__init__(**kwargs) + self.name = None + self.is_data_action = None + self.display = display + self.origin = None + self.action_type = None + + +class OperationDisplay(msrest.serialization.Model): + """Localized display information for this particular operation. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar provider: The localized friendly form of the resource provider name, e.g. "Microsoft + Monitoring Insights" or "Microsoft Compute". + :vartype provider: str + :ivar resource: The localized friendly name of the resource type related to this operation. + E.g. "Virtual Machines" or "Job Schedule Collections". + :vartype resource: str + :ivar operation: The concise, localized friendly name for the operation; suitable for + dropdowns. E.g. "Create or Update Virtual Machine", "Restart Virtual Machine". + :vartype operation: str + :ivar description: The short, localized friendly description of the operation; suitable for + tool tips and detailed views. + :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): + """A list of REST API operations supported by an Azure Resource Provider. It contains an URL link to get the next set of results. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: List of operations supported by the resource provider. + :vartype value: list[~azure.mgmt.managedapplication.v2017_09_01.models.Operation] + :ivar next_link: URL to get the next set of operation list results (if there are any). + :vartype next_link: str + """ + + _validation = { + 'value': {'readonly': True}, + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Operation]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(OperationListResult, self).__init__(**kwargs) + self.value = None + self.next_link = None + + +class Plan(msrest.serialization.Model): + """Plan for the managed application. + + All required parameters must be populated in order to send to Azure. + + :ivar name: Required. The plan name. + :vartype name: str + :ivar publisher: Required. The publisher ID. + :vartype publisher: str + :ivar product: Required. The product code. + :vartype product: str + :ivar promotion_code: The promotion code. + :vartype promotion_code: str + :ivar version: Required. The plan's version. + :vartype version: str + """ + + _validation = { + 'name': {'required': True}, + 'publisher': {'required': True}, + 'product': {'required': True}, + 'version': {'required': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'publisher': {'key': 'publisher', 'type': 'str'}, + 'product': {'key': 'product', 'type': 'str'}, + 'promotion_code': {'key': 'promotionCode', 'type': 'str'}, + 'version': {'key': 'version', 'type': 'str'}, + } + + def __init__( + self, + *, + name: str, + publisher: str, + product: str, + version: str, + promotion_code: Optional[str] = None, + **kwargs + ): + """ + :keyword name: Required. The plan name. + :paramtype name: str + :keyword publisher: Required. The publisher ID. + :paramtype publisher: str + :keyword product: Required. The product code. + :paramtype product: str + :keyword promotion_code: The promotion code. + :paramtype promotion_code: str + :keyword version: Required. The plan's version. + :paramtype version: str + """ + super(Plan, self).__init__(**kwargs) + self.name = name + self.publisher = publisher + self.product = product + self.promotion_code = promotion_code + self.version = version + + +class PlanPatchable(msrest.serialization.Model): + """Plan for the managed application. + + :ivar name: The plan name. + :vartype name: str + :ivar publisher: The publisher ID. + :vartype publisher: str + :ivar product: The product code. + :vartype product: str + :ivar promotion_code: The promotion code. + :vartype promotion_code: str + :ivar version: The plan's version. + :vartype version: str + """ + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'publisher': {'key': 'publisher', 'type': 'str'}, + 'product': {'key': 'product', 'type': 'str'}, + 'promotion_code': {'key': 'promotionCode', 'type': 'str'}, + 'version': {'key': 'version', 'type': 'str'}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + publisher: Optional[str] = None, + product: Optional[str] = None, + promotion_code: Optional[str] = None, + version: Optional[str] = None, + **kwargs + ): + """ + :keyword name: The plan name. + :paramtype name: str + :keyword publisher: The publisher ID. + :paramtype publisher: str + :keyword product: The product code. + :paramtype product: str + :keyword promotion_code: The promotion code. + :paramtype promotion_code: str + :keyword version: The plan's version. + :paramtype version: str + """ + super(PlanPatchable, self).__init__(**kwargs) + self.name = name + self.publisher = publisher + self.product = product + self.promotion_code = promotion_code + self.version = version + + +class Sku(msrest.serialization.Model): + """SKU for the resource. + + All required parameters must be populated in order to send to Azure. + + :ivar name: Required. The SKU name. + :vartype name: str + :ivar tier: The SKU tier. + :vartype tier: str + :ivar size: The SKU size. + :vartype size: str + :ivar family: The SKU family. + :vartype family: str + :ivar model: The SKU model. + :vartype model: str + :ivar capacity: The SKU capacity. + :vartype capacity: int + """ + + _validation = { + 'name': {'required': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'tier': {'key': 'tier', 'type': 'str'}, + 'size': {'key': 'size', 'type': 'str'}, + 'family': {'key': 'family', 'type': 'str'}, + 'model': {'key': 'model', 'type': 'str'}, + 'capacity': {'key': 'capacity', 'type': 'int'}, + } + + def __init__( + self, + *, + name: str, + tier: Optional[str] = None, + size: Optional[str] = None, + family: Optional[str] = None, + model: Optional[str] = None, + capacity: Optional[int] = None, + **kwargs + ): + """ + :keyword name: Required. The SKU name. + :paramtype name: str + :keyword tier: The SKU tier. + :paramtype tier: str + :keyword size: The SKU size. + :paramtype size: str + :keyword family: The SKU family. + :paramtype family: str + :keyword model: The SKU model. + :paramtype model: str + :keyword capacity: The SKU capacity. + :paramtype capacity: int + """ + super(Sku, self).__init__(**kwargs) + self.name = name + self.tier = tier + self.size = size + self.family = family + self.model = model + self.capacity = capacity diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_09_01/models/_patch.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_09_01/models/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_09_01/models/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_09_01/operations/__init__.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_09_01/operations/__init__.py new file mode 100644 index 000000000000..47d8f29e4b2c --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_09_01/operations/__init__.py @@ -0,0 +1,22 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._application_client_operations import ApplicationClientOperationsMixin +from ._applications_operations import ApplicationsOperations +from ._application_definitions_operations import ApplicationDefinitionsOperations + +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk +__all__ = [ + 'ApplicationClientOperationsMixin', + 'ApplicationsOperations', + 'ApplicationDefinitionsOperations', +] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_09_01/operations/_application_client_operations.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_09_01/operations/_application_client_operations.py new file mode 100644 index 000000000000..b11bd1d72243 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_09_01/operations/_application_client_operations.py @@ -0,0 +1,134 @@ +# 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.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._vendor import MixinABC, _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_operations_request( + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-09-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.Solutions/operations") + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + +class ApplicationClientOperationsMixin(MixinABC): + + @distributed_trace + def list_operations( + self, + **kwargs: Any + ) -> Iterable[_models.OperationListResult]: + """Lists all of the available Microsoft.Solutions REST API operations. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either OperationListResult or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.managedapplication.v2017_09_01.models.OperationListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-09-01")) # 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', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_operations_request( + api_version=api_version, + template_url=self.list_operations.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_operations_request( + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list_operations.metadata = {'url': "/providers/Microsoft.Solutions/operations"} # type: ignore diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_09_01/operations/_application_definitions_operations.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_09_01/operations/_application_definitions_operations.py new file mode 100644 index 000000000000..36d2266d0334 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_09_01/operations/_application_definitions_operations.py @@ -0,0 +1,720 @@ +# 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.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._vendor import MixinABC, _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_request( + resource_group_name: str, + application_definition_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-09-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "applicationDefinitionName": _SERIALIZER.url("application_definition_name", application_definition_name, 'str', max_length=64, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_delete_request( + resource_group_name: str, + application_definition_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-09-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "applicationDefinitionName": _SERIALIZER.url("application_definition_name", application_definition_name, 'str', max_length=64, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_create_or_update_request( + resource_group_name: str, + application_definition_name: str, + subscription_id: str, + *, + json: Optional[_models.ApplicationDefinition] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-09-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "applicationDefinitionName": _SERIALIZER.url("application_definition_name", application_definition_name, 'str', max_length=64, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_update_request( + resource_group_name: str, + application_definition_name: str, + subscription_id: str, + *, + json: Optional[_models.ApplicationDefinitionPatchable] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-09-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "applicationDefinitionName": _SERIALIZER.url("application_definition_name", application_definition_name, 'str', max_length=64, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_list_by_resource_group_request( + resource_group_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-09-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_list_by_subscription_request( + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-09-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Solutions/applicationDefinitions") + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + +class ApplicationDefinitionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.managedapplication.v2017_09_01.ApplicationClient`'s + :attr:`application_definitions` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + + @distributed_trace + def get( + self, + resource_group_name: str, + application_definition_name: str, + **kwargs: Any + ) -> Optional[_models.ApplicationDefinition]: + """Gets the managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. + :type application_definition_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ApplicationDefinition, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2017_09_01.models.ApplicationDefinition or None + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-09-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.ApplicationDefinition]] + + + request = build_get_request( + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('ApplicationDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore + + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + application_definition_name: str, + **kwargs: Any + ) -> None: + """Deletes the managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition to delete. + :type application_definition_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-09-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_request( + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore + + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + application_definition_name: str, + parameters: _models.ApplicationDefinition, + **kwargs: Any + ) -> _models.ApplicationDefinition: + """Creates or updates a managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. + :type application_definition_name: str + :param parameters: Parameters supplied to the create or update an managed application + definition. + :type parameters: ~azure.mgmt.managedapplication.v2017_09_01.models.ApplicationDefinition + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ApplicationDefinition, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2017_09_01.models.ApplicationDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-09-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationDefinition] + + _json = self._serialize.body(parameters, 'ApplicationDefinition') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # 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, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('ApplicationDefinition', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('ApplicationDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore + + + @distributed_trace + def update( + self, + resource_group_name: str, + application_definition_name: str, + parameters: _models.ApplicationDefinitionPatchable, + **kwargs: Any + ) -> _models.ApplicationDefinition: + """Updates the managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition to delete. + :type application_definition_name: str + :param parameters: Parameters supplied to the update a managed application definition. + :type parameters: + ~azure.mgmt.managedapplication.v2017_09_01.models.ApplicationDefinitionPatchable + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ApplicationDefinition, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2017_09_01.models.ApplicationDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-09-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationDefinition] + + _json = self._serialize.body(parameters, 'ApplicationDefinitionPatchable') + + request = build_update_request( + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ApplicationDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore + + + @distributed_trace + def list_by_resource_group( + self, + resource_group_name: str, + **kwargs: Any + ) -> Iterable[_models.ApplicationDefinitionListResult]: + """Lists the managed application definitions in a resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ApplicationDefinitionListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.managedapplication.v2017_09_01.models.ApplicationDefinitionListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-09-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationDefinitionListResult] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_resource_group.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ApplicationDefinitionListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions"} # type: ignore + + @distributed_trace + def list_by_subscription( + self, + **kwargs: Any + ) -> Iterable[_models.ApplicationDefinitionListResult]: + """Lists the managed application definitions in a subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ApplicationDefinitionListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.managedapplication.v2017_09_01.models.ApplicationDefinitionListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-09-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationDefinitionListResult] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ApplicationDefinitionListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Solutions/applicationDefinitions"} # type: ignore diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_09_01/operations/_applications_operations.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_09_01/operations/_applications_operations.py new file mode 100644 index 000000000000..59d3344bda2c --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_09_01/operations/_applications_operations.py @@ -0,0 +1,1530 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast + +from msrest import Serializer + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from .._vendor import MixinABC, _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_request( + resource_group_name: str, + application_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-09-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "applicationName": _SERIALIZER.url("application_name", application_name, 'str', max_length=64, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_delete_request_initial( + resource_group_name: str, + application_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-09-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "applicationName": _SERIALIZER.url("application_name", application_name, 'str', max_length=64, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_create_or_update_request_initial( + resource_group_name: str, + application_name: str, + subscription_id: str, + *, + json: Optional[_models.Application] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-09-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "applicationName": _SERIALIZER.url("application_name", application_name, 'str', max_length=64, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_update_request_initial( + resource_group_name: str, + application_name: str, + subscription_id: str, + *, + json: Optional[_models.ApplicationPatchable] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-09-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "applicationName": _SERIALIZER.url("application_name", application_name, 'str', max_length=64, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_list_by_resource_group_request( + resource_group_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-09-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_list_by_subscription_request( + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-09-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Solutions/applications") + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_get_by_id_request( + application_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-09-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/{applicationId}") + path_format_arguments = { + "applicationId": _SERIALIZER.url("application_id", application_id, 'str', skip_quote=True), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_delete_by_id_request_initial( + application_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-09-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/{applicationId}") + path_format_arguments = { + "applicationId": _SERIALIZER.url("application_id", application_id, 'str', skip_quote=True), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_create_or_update_by_id_request_initial( + application_id: str, + *, + json: Optional[_models.Application] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-09-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/{applicationId}") + path_format_arguments = { + "applicationId": _SERIALIZER.url("application_id", application_id, 'str', skip_quote=True), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_update_by_id_request_initial( + application_id: str, + *, + json: Optional[_models.ApplicationPatchable] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-09-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/{applicationId}") + path_format_arguments = { + "applicationId": _SERIALIZER.url("application_id", application_id, 'str', skip_quote=True), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + +class ApplicationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.managedapplication.v2017_09_01.ApplicationClient`'s + :attr:`applications` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + + @distributed_trace + def get( + self, + resource_group_name: str, + application_name: str, + **kwargs: Any + ) -> Optional[_models.Application]: + """Gets the managed application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_name: The name of the managed application. + :type application_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Application, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2017_09_01.models.Application or None + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-09-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.Application]] + + + request = build_get_request( + resource_group_name=resource_group_name, + application_name=application_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('Application', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}"} # type: ignore + + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + application_name: str, + **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-09-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + application_name=application_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}"} # type: ignore + + + @distributed_trace + def begin_delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + application_name: str, + **kwargs: Any + ) -> LROPoller[None]: + """Deletes the managed application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_name: The name of the managed application. + :type application_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-09-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._delete_initial( # type: ignore + resource_group_name=resource_group_name, + application_name=application_name, + api_version=api_version, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}"} # type: ignore + + def _create_or_update_initial( + self, + resource_group_name: str, + application_name: str, + parameters: _models.Application, + **kwargs: Any + ) -> _models.Application: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-09-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Application] + + _json = self._serialize.body(parameters, 'Application') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + application_name=application_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('Application', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('Application', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}"} # type: ignore + + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + application_name: str, + parameters: _models.Application, + **kwargs: Any + ) -> LROPoller[_models.Application]: + """Creates or updates a managed application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_name: The name of the managed application. + :type application_name: str + :param parameters: Parameters supplied to the create or update a managed application. + :type parameters: ~azure.mgmt.managedapplication.v2017_09_01.models.Application + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Application or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.managedapplication.v2017_09_01.models.Application] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-09-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Application] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._create_or_update_initial( # type: ignore + resource_group_name=resource_group_name, + application_name=application_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('Application', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}"} # type: ignore + + def _update_initial( + self, + resource_group_name: str, + application_name: str, + parameters: Optional[_models.ApplicationPatchable] = None, + **kwargs: Any + ) -> _models.ApplicationPatchable: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-09-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationPatchable] + + if parameters is not None: + _json = self._serialize.body(parameters, 'ApplicationPatchable') + else: + _json = None + + request = build_update_request_initial( + resource_group_name=resource_group_name, + application_name=application_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('ApplicationPatchable', pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize('ApplicationPatchable', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}"} # type: ignore + + + @distributed_trace + def begin_update( + self, + resource_group_name: str, + application_name: str, + parameters: Optional[_models.ApplicationPatchable] = None, + **kwargs: Any + ) -> LROPoller[_models.ApplicationPatchable]: + """Updates an existing managed application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_name: The name of the managed application. + :type application_name: str + :param parameters: Parameters supplied to update an existing managed application. Default value + is None. + :type parameters: ~azure.mgmt.managedapplication.v2017_09_01.models.ApplicationPatchable + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ApplicationPatchable or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.managedapplication.v2017_09_01.models.ApplicationPatchable] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-09-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationPatchable] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._update_initial( # type: ignore + resource_group_name=resource_group_name, + application_name=application_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('ApplicationPatchable', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}"} # type: ignore + + @distributed_trace + def list_by_resource_group( + self, + resource_group_name: str, + **kwargs: Any + ) -> Iterable[_models.ApplicationListResult]: + """Lists all the applications within a resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ApplicationListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.managedapplication.v2017_09_01.models.ApplicationListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-09-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationListResult] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_resource_group.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ApplicationListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications"} # type: ignore + + @distributed_trace + def list_by_subscription( + self, + **kwargs: Any + ) -> Iterable[_models.ApplicationListResult]: + """Lists all the applications within a subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ApplicationListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.managedapplication.v2017_09_01.models.ApplicationListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-09-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationListResult] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ApplicationListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Solutions/applications"} # type: ignore + + @distributed_trace + def get_by_id( + self, + application_id: str, + **kwargs: Any + ) -> Optional[_models.Application]: + """Gets the managed application. + + :param application_id: The fully qualified ID of the managed application, including the managed + application name and the managed application resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/Microsoft.Solutions/applications/{application-name}. + :type application_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Application, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2017_09_01.models.Application or None + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-09-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.Application]] + + + request = build_get_by_id_request( + application_id=application_id, + api_version=api_version, + template_url=self.get_by_id.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('Application', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_by_id.metadata = {'url': "/{applicationId}"} # type: ignore + + + def _delete_by_id_initial( # pylint: disable=inconsistent-return-statements + self, + application_id: str, + **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-09-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_by_id_request_initial( + application_id=application_id, + api_version=api_version, + template_url=self._delete_by_id_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_by_id_initial.metadata = {'url': "/{applicationId}"} # type: ignore + + + @distributed_trace + def begin_delete_by_id( # pylint: disable=inconsistent-return-statements + self, + application_id: str, + **kwargs: Any + ) -> LROPoller[None]: + """Deletes the managed application. + + :param application_id: The fully qualified ID of the managed application, including the managed + application name and the managed application resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/Microsoft.Solutions/applications/{application-name}. + :type application_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-09-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._delete_by_id_initial( # type: ignore + application_id=application_id, + api_version=api_version, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete_by_id.metadata = {'url': "/{applicationId}"} # type: ignore + + def _create_or_update_by_id_initial( + self, + application_id: str, + parameters: _models.Application, + **kwargs: Any + ) -> _models.Application: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-09-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Application] + + _json = self._serialize.body(parameters, 'Application') + + request = build_create_or_update_by_id_request_initial( + application_id=application_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._create_or_update_by_id_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('Application', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('Application', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_by_id_initial.metadata = {'url': "/{applicationId}"} # type: ignore + + + @distributed_trace + def begin_create_or_update_by_id( + self, + application_id: str, + parameters: _models.Application, + **kwargs: Any + ) -> LROPoller[_models.Application]: + """Creates or updates a managed application. + + :param application_id: The fully qualified ID of the managed application, including the managed + application name and the managed application resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/Microsoft.Solutions/applications/{application-name}. + :type application_id: str + :param parameters: Parameters supplied to the create or update a managed application. + :type parameters: ~azure.mgmt.managedapplication.v2017_09_01.models.Application + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Application or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.managedapplication.v2017_09_01.models.Application] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-09-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Application] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._create_or_update_by_id_initial( # type: ignore + application_id=application_id, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('Application', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update_by_id.metadata = {'url': "/{applicationId}"} # type: ignore + + def _update_by_id_initial( + self, + application_id: str, + parameters: Optional[_models.ApplicationPatchable] = None, + **kwargs: Any + ) -> _models.ApplicationPatchable: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-09-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationPatchable] + + if parameters is not None: + _json = self._serialize.body(parameters, 'ApplicationPatchable') + else: + _json = None + + request = build_update_by_id_request_initial( + application_id=application_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._update_by_id_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('ApplicationPatchable', pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize('ApplicationPatchable', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _update_by_id_initial.metadata = {'url': "/{applicationId}"} # type: ignore + + + @distributed_trace + def begin_update_by_id( + self, + application_id: str, + parameters: Optional[_models.ApplicationPatchable] = None, + **kwargs: Any + ) -> LROPoller[_models.ApplicationPatchable]: + """Updates an existing managed application. + + :param application_id: The fully qualified ID of the managed application, including the managed + application name and the managed application resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/Microsoft.Solutions/applications/{application-name}. + :type application_id: str + :param parameters: Parameters supplied to update an existing managed application. Default value + is None. + :type parameters: ~azure.mgmt.managedapplication.v2017_09_01.models.ApplicationPatchable + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ApplicationPatchable or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.managedapplication.v2017_09_01.models.ApplicationPatchable] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-09-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationPatchable] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._update_by_id_initial( # type: ignore + application_id=application_id, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('ApplicationPatchable', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_update_by_id.metadata = {'url': "/{applicationId}"} # type: ignore diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_09_01/operations/_patch.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_09_01/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_09_01/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_09_01/py.typed b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_09_01/py.typed new file mode 100644 index 000000000000..e5aff4f83af8 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_09_01/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_12_01/__init__.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_12_01/__init__.py new file mode 100644 index 000000000000..2e61ca12e56a --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_12_01/__init__.py @@ -0,0 +1,23 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._application_client import ApplicationClient +from ._version import VERSION + +__version__ = VERSION + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk +__all__ = ['ApplicationClient'] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_12_01/_application_client.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_12_01/_application_client.py new file mode 100644 index 000000000000..735bb423a452 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_12_01/_application_client.py @@ -0,0 +1,106 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from 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 ApplicationClientConfiguration +from .operations import ApplicationClientOperationsMixin, ApplicationDefinitionsOperations, ApplicationsOperations + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential + +class ApplicationClient(ApplicationClientOperationsMixin): + """ARM applications. + + :ivar applications: ApplicationsOperations operations + :vartype applications: + azure.mgmt.managedapplication.v2017_12_01.operations.ApplicationsOperations + :ivar application_definitions: ApplicationDefinitionsOperations operations + :vartype application_definitions: + azure.mgmt.managedapplication.v2017_12_01.operations.ApplicationDefinitionsOperations + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials.TokenCredential + :param subscription_id: The ID of the target subscription. + :type subscription_id: str + :param base_url: Service URL. Default value is "https://management.azure.com". + :type base_url: str + :keyword api_version: Api Version. Default value is "2017-12-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + """ + + def __init__( + self, + credential: "TokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = ApplicationClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.applications = ApplicationsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.application_definitions = ApplicationDefinitionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + + + 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: () -> ApplicationClient + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (Any) -> None + self._client.__exit__(*exc_details) diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_12_01/_configuration.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_12_01/_configuration.py new file mode 100644 index 000000000000..a4e273b6580e --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_12_01/_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 ApplicationClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes + """Configuration for ApplicationClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials.TokenCredential + :param subscription_id: The ID of the target subscription. + :type subscription_id: str + :keyword api_version: Api Version. Default value is "2017-12-01". 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(ApplicationClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2017-12-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.") + + 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-managedapplication/{}'.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/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_12_01/_metadata.json b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_12_01/_metadata.json new file mode 100644 index 000000000000..3bbbf6cbb8f5 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_12_01/_metadata.json @@ -0,0 +1,122 @@ +{ + "chosen_version": "2017-12-01", + "total_api_version_list": ["2017-12-01"], + "client": { + "name": "ApplicationClient", + "filename": "_application_client", + "description": "ARM applications.", + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": null, + "azure_arm": true, + "has_lro_operations": true, + "client_side_validation": false, + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ApplicationClientConfiguration\"], \"._operations_mixin\": [\"ApplicationClientOperationsMixin\"]}, \"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\": [\"ApplicationClientConfiguration\"], \"._operations_mixin\": [\"ApplicationClientOperationsMixin\"]}, \"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": { + "applications": "ApplicationsOperations", + "application_definitions": "ApplicationDefinitionsOperations" + }, + "operation_mixins": { + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Iterable\"]}, \"azurecore\": {\"azure.core.paging\": [\"ItemPaged\"]}}, \"regular\": {\"local\": {\".\": [[\"models\", \"_models\"]]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"AsyncIterable\"]}, \"azurecore\": {\"azure.core.async_paging\": [\"AsyncItemPaged\"]}}, \"regular\": {\"local\": {\"..\": [[\"models\", \"_models\"]]}}}", + "operations": { + "list_operations" : { + "sync": { + "signature": "def list_operations(\n self,\n **kwargs # type: Any\n):\n # type: (...) -\u003e Iterable[_models.OperationListResult]\n", + "doc": "\"\"\"Lists all of the available Microsoft.Solutions REST API operations.\n\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: An iterator like instance of either OperationListResult or the result of cls(response)\n:rtype:\n ~azure.core.paging.ItemPaged[~azure.mgmt.managedapplication.v2017_12_01.models.OperationListResult]\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"", + "call": "**kwargs" + }, + "async": { + "coroutine": false, + "signature": "def list_operations(\n self,\n **kwargs: Any\n) -\u003e AsyncIterable[_models.OperationListResult]:\n", + "doc": "\"\"\"Lists all of the available Microsoft.Solutions REST API operations.\n\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: An iterator like instance of either OperationListResult or the result of cls(response)\n:rtype:\n ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.managedapplication.v2017_12_01.models.OperationListResult]\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"", + "call": "**kwargs" + } + } + } + } +} \ No newline at end of file diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_12_01/_patch.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_12_01/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_12_01/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_12_01/_vendor.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_12_01/_vendor.py new file mode 100644 index 000000000000..bf1845cabc0f --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_12_01/_vendor.py @@ -0,0 +1,45 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from abc import ABC +from typing import TYPE_CHECKING + +from azure.core.pipeline.transport import HttpRequest + +from ._configuration import ApplicationClientConfiguration + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from msrest import Deserializer, Serializer + + from azure.core import PipelineClient + +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) + +class MixinABC(ABC): + """DO NOT use this class. It is for internal typing use only.""" + _client: "PipelineClient" + _config: ApplicationClientConfiguration + _serialize: "Serializer" + _deserialize: "Deserializer" diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_12_01/_version.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_12_01/_version.py new file mode 100644 index 000000000000..e5754a47ce68 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_12_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/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_12_01/aio/__init__.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_12_01/aio/__init__.py new file mode 100644 index 000000000000..c90626a31421 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_12_01/aio/__init__.py @@ -0,0 +1,20 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._application_client import ApplicationClient + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk +__all__ = ['ApplicationClient'] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_12_01/aio/_application_client.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_12_01/aio/_application_client.py new file mode 100644 index 000000000000..c015a81949f5 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_12_01/aio/_application_client.py @@ -0,0 +1,103 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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 ApplicationClientConfiguration +from .operations import ApplicationClientOperationsMixin, ApplicationDefinitionsOperations, ApplicationsOperations + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + +class ApplicationClient(ApplicationClientOperationsMixin): + """ARM applications. + + :ivar applications: ApplicationsOperations operations + :vartype applications: + azure.mgmt.managedapplication.v2017_12_01.aio.operations.ApplicationsOperations + :ivar application_definitions: ApplicationDefinitionsOperations operations + :vartype application_definitions: + azure.mgmt.managedapplication.v2017_12_01.aio.operations.ApplicationDefinitionsOperations + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :param subscription_id: The ID of the target subscription. + :type subscription_id: str + :param base_url: Service URL. Default value is "https://management.azure.com". + :type base_url: str + :keyword api_version: Api Version. Default value is "2017-12-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = ApplicationClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.applications = ApplicationsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.application_definitions = ApplicationDefinitionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + + + 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) -> "ApplicationClient": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_12_01/aio/_configuration.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_12_01/aio/_configuration.py new file mode 100644 index 000000000000..0619c765d131 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_12_01/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 ApplicationClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes + """Configuration for ApplicationClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :param subscription_id: The ID of the target subscription. + :type subscription_id: str + :keyword api_version: Api Version. Default value is "2017-12-01". 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(ApplicationClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2017-12-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.") + + 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-managedapplication/{}'.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/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_12_01/aio/_patch.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_12_01/aio/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_12_01/aio/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_12_01/aio/_vendor.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_12_01/aio/_vendor.py new file mode 100644 index 000000000000..da14e4f71f0e --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_12_01/aio/_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 abc import ABC +from typing import TYPE_CHECKING + +from azure.core.pipeline.transport import HttpRequest + +from ._configuration import ApplicationClientConfiguration + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from msrest import Deserializer, Serializer + + from azure.core import AsyncPipelineClient + + +class MixinABC(ABC): + """DO NOT use this class. It is for internal typing use only.""" + _client: "AsyncPipelineClient" + _config: ApplicationClientConfiguration + _serialize: "Serializer" + _deserialize: "Deserializer" diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_12_01/aio/operations/__init__.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_12_01/aio/operations/__init__.py new file mode 100644 index 000000000000..47d8f29e4b2c --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_12_01/aio/operations/__init__.py @@ -0,0 +1,22 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._application_client_operations import ApplicationClientOperationsMixin +from ._applications_operations import ApplicationsOperations +from ._application_definitions_operations import ApplicationDefinitionsOperations + +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk +__all__ = [ + 'ApplicationClientOperationsMixin', + 'ApplicationsOperations', + 'ApplicationDefinitionsOperations', +] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_12_01/aio/operations/_application_client_operations.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_12_01/aio/operations/_application_client_operations.py new file mode 100644 index 000000000000..7c9538cd93c4 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_12_01/aio/operations/_application_client_operations.py @@ -0,0 +1,105 @@ +# 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.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._application_client_operations import build_list_operations_request +from .._vendor import MixinABC +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class ApplicationClientOperationsMixin(MixinABC): + + @distributed_trace + def list_operations( + self, + **kwargs: Any + ) -> AsyncIterable[_models.OperationListResult]: + """Lists all of the available Microsoft.Solutions REST API operations. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either OperationListResult or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.managedapplication.v2017_12_01.models.OperationListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # 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', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_operations_request( + api_version=api_version, + template_url=self.list_operations.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_operations_request( + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list_operations.metadata = {'url': "/providers/Microsoft.Solutions/operations"} # type: ignore diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_12_01/aio/operations/_application_definitions_operations.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_12_01/aio/operations/_application_definitions_operations.py new file mode 100644 index 000000000000..2c6b8abe155e --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_12_01/aio/operations/_application_definitions_operations.py @@ -0,0 +1,487 @@ +# 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.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._application_definitions_operations import build_create_or_update_request, build_delete_request, build_get_request, build_list_by_resource_group_request, build_list_by_subscription_request, build_update_request +from .._vendor import MixinABC +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class ApplicationDefinitionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.managedapplication.v2017_12_01.aio.ApplicationClient`'s + :attr:`application_definitions` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + application_definition_name: str, + **kwargs: Any + ) -> Optional[_models.ApplicationDefinition]: + """Gets the managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. + :type application_definition_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ApplicationDefinition, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2017_12_01.models.ApplicationDefinition or None + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.ApplicationDefinition]] + + + request = build_get_request( + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('ApplicationDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore + + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + application_definition_name: str, + **kwargs: Any + ) -> None: + """Deletes the managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition to delete. + :type application_definition_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_request( + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore + + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + application_definition_name: str, + parameters: _models.ApplicationDefinition, + **kwargs: Any + ) -> _models.ApplicationDefinition: + """Creates or updates a managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. + :type application_definition_name: str + :param parameters: Parameters supplied to the create or update an managed application + definition. + :type parameters: ~azure.mgmt.managedapplication.v2017_12_01.models.ApplicationDefinition + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ApplicationDefinition, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2017_12_01.models.ApplicationDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationDefinition] + + _json = self._serialize.body(parameters, 'ApplicationDefinition') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # 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, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('ApplicationDefinition', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('ApplicationDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore + + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + application_definition_name: str, + parameters: _models.ApplicationDefinitionPatchable, + **kwargs: Any + ) -> _models.ApplicationDefinition: + """Updates the managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. + :type application_definition_name: str + :param parameters: Parameters supplied to the update a managed application definition. + :type parameters: + ~azure.mgmt.managedapplication.v2017_12_01.models.ApplicationDefinitionPatchable + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ApplicationDefinition, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2017_12_01.models.ApplicationDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationDefinition] + + _json = self._serialize.body(parameters, 'ApplicationDefinitionPatchable') + + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ApplicationDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore + + + @distributed_trace + def list_by_resource_group( + self, + resource_group_name: str, + **kwargs: Any + ) -> AsyncIterable[_models.ApplicationDefinitionListResult]: + """Lists the managed application definitions in a resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ApplicationDefinitionListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.managedapplication.v2017_12_01.models.ApplicationDefinitionListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationDefinitionListResult] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_resource_group.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ApplicationDefinitionListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions"} # type: ignore + + @distributed_trace + def list_by_subscription( + self, + **kwargs: Any + ) -> AsyncIterable[_models.ApplicationDefinitionListResult]: + """Lists the managed application definitions in a subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ApplicationDefinitionListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.managedapplication.v2017_12_01.models.ApplicationDefinitionListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationDefinitionListResult] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ApplicationDefinitionListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Solutions/applicationDefinitions"} # type: ignore diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_12_01/aio/operations/_applications_operations.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_12_01/aio/operations/_applications_operations.py new file mode 100644 index 000000000000..e4f5a7a87926 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_12_01/aio/operations/_applications_operations.py @@ -0,0 +1,1149 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union, cast + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._applications_operations import build_create_or_update_by_id_request_initial, build_create_or_update_request_initial, build_delete_by_id_request_initial, build_delete_request_initial, build_get_by_id_request, build_get_request, build_list_by_resource_group_request, build_list_by_subscription_request, build_update_by_id_request_initial, build_update_request_initial +from .._vendor import MixinABC +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class ApplicationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.managedapplication.v2017_12_01.aio.ApplicationClient`'s + :attr:`applications` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + application_name: str, + **kwargs: Any + ) -> Optional[_models.Application]: + """Gets the managed application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_name: The name of the managed application. + :type application_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Application, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2017_12_01.models.Application or None + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.Application]] + + + request = build_get_request( + resource_group_name=resource_group_name, + application_name=application_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('Application', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}"} # type: ignore + + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + application_name: str, + **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + application_name=application_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}"} # type: ignore + + + @distributed_trace_async + async def begin_delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + application_name: str, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes the managed application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_name: The name of the managed application. + :type application_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._delete_initial( # type: ignore + resource_group_name=resource_group_name, + application_name=application_name, + api_version=api_version, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}"} # type: ignore + + async def _create_or_update_initial( + self, + resource_group_name: str, + application_name: str, + parameters: _models.Application, + **kwargs: Any + ) -> _models.Application: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Application] + + _json = self._serialize.body(parameters, 'Application') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + application_name=application_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('Application', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('Application', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}"} # type: ignore + + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + application_name: str, + parameters: _models.Application, + **kwargs: Any + ) -> AsyncLROPoller[_models.Application]: + """Creates or updates a managed application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_name: The name of the managed application. + :type application_name: str + :param parameters: Parameters supplied to the create or update a managed application. + :type parameters: ~azure.mgmt.managedapplication.v2017_12_01.models.Application + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either Application or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.managedapplication.v2017_12_01.models.Application] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Application] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._create_or_update_initial( # type: ignore + resource_group_name=resource_group_name, + application_name=application_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('Application', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}"} # type: ignore + + async def _update_initial( + self, + resource_group_name: str, + application_name: str, + parameters: Optional[_models.ApplicationPatchable] = None, + **kwargs: Any + ) -> _models.ApplicationPatchable: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationPatchable] + + if parameters is not None: + _json = self._serialize.body(parameters, 'ApplicationPatchable') + else: + _json = None + + request = build_update_request_initial( + resource_group_name=resource_group_name, + application_name=application_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('ApplicationPatchable', pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize('ApplicationPatchable', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}"} # type: ignore + + + @distributed_trace_async + async def begin_update( + self, + resource_group_name: str, + application_name: str, + parameters: Optional[_models.ApplicationPatchable] = None, + **kwargs: Any + ) -> AsyncLROPoller[_models.ApplicationPatchable]: + """Updates an existing managed application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_name: The name of the managed application. + :type application_name: str + :param parameters: Parameters supplied to update an existing managed application. Default value + is None. + :type parameters: ~azure.mgmt.managedapplication.v2017_12_01.models.ApplicationPatchable + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ApplicationPatchable or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.managedapplication.v2017_12_01.models.ApplicationPatchable] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationPatchable] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._update_initial( # type: ignore + resource_group_name=resource_group_name, + application_name=application_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('ApplicationPatchable', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}"} # type: ignore + + @distributed_trace + def list_by_resource_group( + self, + resource_group_name: str, + **kwargs: Any + ) -> AsyncIterable[_models.ApplicationListResult]: + """Lists all the applications within a resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ApplicationListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.managedapplication.v2017_12_01.models.ApplicationListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationListResult] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_resource_group.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ApplicationListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications"} # type: ignore + + @distributed_trace + def list_by_subscription( + self, + **kwargs: Any + ) -> AsyncIterable[_models.ApplicationListResult]: + """Gets all the applications within a subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ApplicationListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.managedapplication.v2017_12_01.models.ApplicationListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationListResult] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ApplicationListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Solutions/applications"} # type: ignore + + @distributed_trace_async + async def get_by_id( + self, + application_id: str, + **kwargs: Any + ) -> Optional[_models.Application]: + """Gets the managed application. + + :param application_id: The fully qualified ID of the managed application, including the managed + application name and the managed application resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/Microsoft.Solutions/applications/{application-name}. + :type application_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Application, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2017_12_01.models.Application or None + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.Application]] + + + request = build_get_by_id_request( + application_id=application_id, + api_version=api_version, + template_url=self.get_by_id.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('Application', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_by_id.metadata = {'url': "/{applicationId}"} # type: ignore + + + async def _delete_by_id_initial( # pylint: disable=inconsistent-return-statements + self, + application_id: str, + **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_by_id_request_initial( + application_id=application_id, + api_version=api_version, + template_url=self._delete_by_id_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_by_id_initial.metadata = {'url': "/{applicationId}"} # type: ignore + + + @distributed_trace_async + async def begin_delete_by_id( # pylint: disable=inconsistent-return-statements + self, + application_id: str, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes the managed application. + + :param application_id: The fully qualified ID of the managed application, including the managed + application name and the managed application resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/Microsoft.Solutions/applications/{application-name}. + :type application_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._delete_by_id_initial( # type: ignore + application_id=application_id, + api_version=api_version, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete_by_id.metadata = {'url': "/{applicationId}"} # type: ignore + + async def _create_or_update_by_id_initial( + self, + application_id: str, + parameters: _models.Application, + **kwargs: Any + ) -> _models.Application: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Application] + + _json = self._serialize.body(parameters, 'Application') + + request = build_create_or_update_by_id_request_initial( + application_id=application_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._create_or_update_by_id_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('Application', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('Application', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_by_id_initial.metadata = {'url': "/{applicationId}"} # type: ignore + + + @distributed_trace_async + async def begin_create_or_update_by_id( + self, + application_id: str, + parameters: _models.Application, + **kwargs: Any + ) -> AsyncLROPoller[_models.Application]: + """Creates or updates a managed application. + + :param application_id: The fully qualified ID of the managed application, including the managed + application name and the managed application resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/Microsoft.Solutions/applications/{application-name}. + :type application_id: str + :param parameters: Parameters supplied to the create or update a managed application. + :type parameters: ~azure.mgmt.managedapplication.v2017_12_01.models.Application + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either Application or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.managedapplication.v2017_12_01.models.Application] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Application] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._create_or_update_by_id_initial( # type: ignore + application_id=application_id, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('Application', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update_by_id.metadata = {'url': "/{applicationId}"} # type: ignore + + async def _update_by_id_initial( + self, + application_id: str, + parameters: Optional[_models.ApplicationPatchable] = None, + **kwargs: Any + ) -> _models.ApplicationPatchable: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationPatchable] + + if parameters is not None: + _json = self._serialize.body(parameters, 'ApplicationPatchable') + else: + _json = None + + request = build_update_by_id_request_initial( + application_id=application_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._update_by_id_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('ApplicationPatchable', pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize('ApplicationPatchable', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _update_by_id_initial.metadata = {'url': "/{applicationId}"} # type: ignore + + + @distributed_trace_async + async def begin_update_by_id( + self, + application_id: str, + parameters: Optional[_models.ApplicationPatchable] = None, + **kwargs: Any + ) -> AsyncLROPoller[_models.ApplicationPatchable]: + """Updates an existing managed application. + + :param application_id: The fully qualified ID of the managed application, including the managed + application name and the managed application resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/Microsoft.Solutions/applications/{application-name}. + :type application_id: str + :param parameters: Parameters supplied to update an existing managed application. Default value + is None. + :type parameters: ~azure.mgmt.managedapplication.v2017_12_01.models.ApplicationPatchable + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ApplicationPatchable or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.managedapplication.v2017_12_01.models.ApplicationPatchable] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationPatchable] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._update_by_id_initial( # type: ignore + application_id=application_id, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('ApplicationPatchable', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_update_by_id.metadata = {'url': "/{applicationId}"} # type: ignore diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_12_01/aio/operations/_patch.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_12_01/aio/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_12_01/aio/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_12_01/models/__init__.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_12_01/models/__init__.py new file mode 100644 index 000000000000..769407b4688b --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_12_01/models/__init__.py @@ -0,0 +1,69 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._models_py3 import Application +from ._models_py3 import ApplicationArtifact +from ._models_py3 import ApplicationDefinition +from ._models_py3 import ApplicationDefinitionListResult +from ._models_py3 import ApplicationDefinitionPatchable +from ._models_py3 import ApplicationListResult +from ._models_py3 import ApplicationPatchable +from ._models_py3 import ApplicationProviderAuthorization +from ._models_py3 import ErrorAdditionalInfo +from ._models_py3 import ErrorDetail +from ._models_py3 import ErrorResponse +from ._models_py3 import GenericResource +from ._models_py3 import Identity +from ._models_py3 import Operation +from ._models_py3 import OperationDisplay +from ._models_py3 import OperationListResult +from ._models_py3 import Plan +from ._models_py3 import PlanPatchable +from ._models_py3 import Resource +from ._models_py3 import Sku + + +from ._application_client_enums import ( + ActionType, + ApplicationArtifactType, + ApplicationLockLevel, + Origin, + ProvisioningState, +) +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk +__all__ = [ + 'Application', + 'ApplicationArtifact', + 'ApplicationDefinition', + 'ApplicationDefinitionListResult', + 'ApplicationDefinitionPatchable', + 'ApplicationListResult', + 'ApplicationPatchable', + 'ApplicationProviderAuthorization', + 'ErrorAdditionalInfo', + 'ErrorDetail', + 'ErrorResponse', + 'GenericResource', + 'Identity', + 'Operation', + 'OperationDisplay', + 'OperationListResult', + 'Plan', + 'PlanPatchable', + 'Resource', + 'Sku', + 'ActionType', + 'ApplicationArtifactType', + 'ApplicationLockLevel', + 'Origin', + 'ProvisioningState', +] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_12_01/models/_application_client_enums.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_12_01/models/_application_client_enums.py new file mode 100644 index 000000000000..4cdef06e66d1 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_12_01/models/_application_client_enums.py @@ -0,0 +1,57 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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 azure.core import CaseInsensitiveEnumMeta + + +class ActionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. + """ + + INTERNAL = "Internal" + +class ApplicationArtifactType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The managed application artifact type. + """ + + TEMPLATE = "Template" + CUSTOM = "Custom" + +class ApplicationLockLevel(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The managed application lock level. + """ + + CAN_NOT_DELETE = "CanNotDelete" + READ_ONLY = "ReadOnly" + NONE = "None" + +class Origin(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit + logs UX. Default value is "user,system" + """ + + USER = "user" + SYSTEM = "system" + USER_SYSTEM = "user,system" + +class ProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Provisioning status of the managed application. + """ + + ACCEPTED = "Accepted" + RUNNING = "Running" + READY = "Ready" + CREATING = "Creating" + CREATED = "Created" + DELETING = "Deleting" + DELETED = "Deleted" + CANCELED = "Canceled" + FAILED = "Failed" + SUCCEEDED = "Succeeded" + UPDATING = "Updating" diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_12_01/models/_models_py3.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_12_01/models/_models_py3.py new file mode 100644 index 000000000000..f8c3fb5834ee --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_12_01/models/_models_py3.py @@ -0,0 +1,1175 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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, Dict, List, Optional, TYPE_CHECKING, Union + +from azure.core.exceptions import HttpResponseError +import msrest.serialization + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + import __init__ as _models + + +class Resource(msrest.serialization.Model): + """Resource information. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Resource ID. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar location: Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'location': {'key': 'location', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + } + + def __init__( + self, + *, + location: Optional[str] = None, + tags: Optional[Dict[str, str]] = None, + **kwargs + ): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + """ + super(Resource, self).__init__(**kwargs) + self.id = None + self.name = None + self.type = None + self.location = location + self.tags = tags + + +class GenericResource(Resource): + """Resource information. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Resource ID. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar location: Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar managed_by: ID of the resource that manages this resource. + :vartype managed_by: str + :ivar sku: The SKU of the resource. + :vartype sku: ~azure.mgmt.managedapplication.v2017_12_01.models.Sku + :ivar identity: The identity of the resource. + :vartype identity: ~azure.mgmt.managedapplication.v2017_12_01.models.Identity + """ + + _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'}, + 'location': {'key': 'location', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + 'managed_by': {'key': 'managedBy', 'type': 'str'}, + 'sku': {'key': 'sku', 'type': 'Sku'}, + 'identity': {'key': 'identity', 'type': 'Identity'}, + } + + def __init__( + self, + *, + location: Optional[str] = None, + tags: Optional[Dict[str, str]] = None, + managed_by: Optional[str] = None, + sku: Optional["_models.Sku"] = None, + identity: Optional["_models.Identity"] = None, + **kwargs + ): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword managed_by: ID of the resource that manages this resource. + :paramtype managed_by: str + :keyword sku: The SKU of the resource. + :paramtype sku: ~azure.mgmt.managedapplication.v2017_12_01.models.Sku + :keyword identity: The identity of the resource. + :paramtype identity: ~azure.mgmt.managedapplication.v2017_12_01.models.Identity + """ + super(GenericResource, self).__init__(location=location, tags=tags, **kwargs) + self.managed_by = managed_by + self.sku = sku + self.identity = identity + + +class Application(GenericResource): + """Information about managed application. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar id: Resource ID. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar location: Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar managed_by: ID of the resource that manages this resource. + :vartype managed_by: str + :ivar sku: The SKU of the resource. + :vartype sku: ~azure.mgmt.managedapplication.v2017_12_01.models.Sku + :ivar identity: The identity of the resource. + :vartype identity: ~azure.mgmt.managedapplication.v2017_12_01.models.Identity + :ivar plan: The plan information. + :vartype plan: ~azure.mgmt.managedapplication.v2017_12_01.models.Plan + :ivar kind: Required. The kind of the managed application. Allowed values are MarketPlace and + ServiceCatalog. + :vartype kind: str + :ivar managed_resource_group_id: Required. The managed resource group Id. + :vartype managed_resource_group_id: str + :ivar application_definition_id: The fully qualified path of managed application definition Id. + :vartype application_definition_id: str + :ivar parameters: Name and value pairs that define the managed application parameters. It can + be a JObject or a well formed JSON string. + :vartype parameters: any + :ivar outputs: Name and value pairs that define the managed application outputs. + :vartype outputs: any + :ivar provisioning_state: The managed application provisioning state. Known values are: + "Accepted", "Running", "Ready", "Creating", "Created", "Deleting", "Deleted", "Canceled", + "Failed", "Succeeded", "Updating". + :vartype provisioning_state: str or + ~azure.mgmt.managedapplication.v2017_12_01.models.ProvisioningState + :ivar ui_definition_uri: The blob URI where the UI definition file is located. + :vartype ui_definition_uri: str + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'kind': {'required': True, 'pattern': r'^[-\w\._,\(\)]+$'}, + 'managed_resource_group_id': {'required': True}, + 'outputs': {'readonly': True}, + 'provisioning_state': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'location': {'key': 'location', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + 'managed_by': {'key': 'managedBy', 'type': 'str'}, + 'sku': {'key': 'sku', 'type': 'Sku'}, + 'identity': {'key': 'identity', 'type': 'Identity'}, + 'plan': {'key': 'plan', 'type': 'Plan'}, + 'kind': {'key': 'kind', 'type': 'str'}, + 'managed_resource_group_id': {'key': 'properties.managedResourceGroupId', 'type': 'str'}, + 'application_definition_id': {'key': 'properties.applicationDefinitionId', 'type': 'str'}, + 'parameters': {'key': 'properties.parameters', 'type': 'object'}, + 'outputs': {'key': 'properties.outputs', 'type': 'object'}, + 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + 'ui_definition_uri': {'key': 'properties.uiDefinitionUri', 'type': 'str'}, + } + + def __init__( + self, + *, + kind: str, + managed_resource_group_id: str, + location: Optional[str] = None, + tags: Optional[Dict[str, str]] = None, + managed_by: Optional[str] = None, + sku: Optional["_models.Sku"] = None, + identity: Optional["_models.Identity"] = None, + plan: Optional["_models.Plan"] = None, + application_definition_id: Optional[str] = None, + parameters: Optional[Any] = None, + ui_definition_uri: Optional[str] = None, + **kwargs + ): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword managed_by: ID of the resource that manages this resource. + :paramtype managed_by: str + :keyword sku: The SKU of the resource. + :paramtype sku: ~azure.mgmt.managedapplication.v2017_12_01.models.Sku + :keyword identity: The identity of the resource. + :paramtype identity: ~azure.mgmt.managedapplication.v2017_12_01.models.Identity + :keyword plan: The plan information. + :paramtype plan: ~azure.mgmt.managedapplication.v2017_12_01.models.Plan + :keyword kind: Required. The kind of the managed application. Allowed values are MarketPlace + and ServiceCatalog. + :paramtype kind: str + :keyword managed_resource_group_id: Required. The managed resource group Id. + :paramtype managed_resource_group_id: str + :keyword application_definition_id: The fully qualified path of managed application definition + Id. + :paramtype application_definition_id: str + :keyword parameters: Name and value pairs that define the managed application parameters. It + can be a JObject or a well formed JSON string. + :paramtype parameters: any + :keyword ui_definition_uri: The blob URI where the UI definition file is located. + :paramtype ui_definition_uri: str + """ + super(Application, self).__init__(location=location, tags=tags, managed_by=managed_by, sku=sku, identity=identity, **kwargs) + self.plan = plan + self.kind = kind + self.managed_resource_group_id = managed_resource_group_id + self.application_definition_id = application_definition_id + self.parameters = parameters + self.outputs = None + self.provisioning_state = None + self.ui_definition_uri = ui_definition_uri + + +class ApplicationArtifact(msrest.serialization.Model): + """Managed application artifact. + + :ivar name: The managed application artifact name. + :vartype name: str + :ivar uri: The managed application artifact blob uri. + :vartype uri: str + :ivar type: The managed application artifact type. Known values are: "Template", "Custom". + :vartype type: str or ~azure.mgmt.managedapplication.v2017_12_01.models.ApplicationArtifactType + """ + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'uri': {'key': 'uri', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + uri: Optional[str] = None, + type: Optional[Union[str, "_models.ApplicationArtifactType"]] = None, + **kwargs + ): + """ + :keyword name: The managed application artifact name. + :paramtype name: str + :keyword uri: The managed application artifact blob uri. + :paramtype uri: str + :keyword type: The managed application artifact type. Known values are: "Template", "Custom". + :paramtype type: str or + ~azure.mgmt.managedapplication.v2017_12_01.models.ApplicationArtifactType + """ + super(ApplicationArtifact, self).__init__(**kwargs) + self.name = name + self.uri = uri + self.type = type + + +class ApplicationDefinition(GenericResource): + """Information about managed application definition. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar id: Resource ID. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar location: Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar managed_by: ID of the resource that manages this resource. + :vartype managed_by: str + :ivar sku: The SKU of the resource. + :vartype sku: ~azure.mgmt.managedapplication.v2017_12_01.models.Sku + :ivar identity: The identity of the resource. + :vartype identity: ~azure.mgmt.managedapplication.v2017_12_01.models.Identity + :ivar lock_level: Required. The managed application lock level. Known values are: + "CanNotDelete", "ReadOnly", "None". + :vartype lock_level: str or + ~azure.mgmt.managedapplication.v2017_12_01.models.ApplicationLockLevel + :ivar display_name: The managed application definition display name. + :vartype display_name: str + :ivar is_enabled: A value indicating whether the package is enabled or not. + :vartype is_enabled: str + :ivar authorizations: Required. The managed application provider authorizations. + :vartype authorizations: + list[~azure.mgmt.managedapplication.v2017_12_01.models.ApplicationProviderAuthorization] + :ivar artifacts: The collection of managed application artifacts. The portal will use the files + specified as artifacts to construct the user experience of creating a managed application from + a managed application definition. + :vartype artifacts: list[~azure.mgmt.managedapplication.v2017_12_01.models.ApplicationArtifact] + :ivar description: The managed application definition description. + :vartype description: str + :ivar package_file_uri: The managed application definition package file Uri. Use this element. + :vartype package_file_uri: str + :ivar main_template: The inline main template json which has resources to be provisioned. It + can be a JObject or well-formed JSON string. + :vartype main_template: any + :ivar create_ui_definition: The createUiDefinition json for the backing template with + Microsoft.Solutions/applications resource. It can be a JObject or well-formed JSON string. + :vartype create_ui_definition: any + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'lock_level': {'required': True}, + 'authorizations': {'required': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'location': {'key': 'location', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + 'managed_by': {'key': 'managedBy', 'type': 'str'}, + 'sku': {'key': 'sku', 'type': 'Sku'}, + 'identity': {'key': 'identity', 'type': 'Identity'}, + 'lock_level': {'key': 'properties.lockLevel', 'type': 'str'}, + 'display_name': {'key': 'properties.displayName', 'type': 'str'}, + 'is_enabled': {'key': 'properties.isEnabled', 'type': 'str'}, + 'authorizations': {'key': 'properties.authorizations', 'type': '[ApplicationProviderAuthorization]'}, + 'artifacts': {'key': 'properties.artifacts', 'type': '[ApplicationArtifact]'}, + 'description': {'key': 'properties.description', 'type': 'str'}, + 'package_file_uri': {'key': 'properties.packageFileUri', 'type': 'str'}, + 'main_template': {'key': 'properties.mainTemplate', 'type': 'object'}, + 'create_ui_definition': {'key': 'properties.createUiDefinition', 'type': 'object'}, + } + + def __init__( + self, + *, + lock_level: Union[str, "_models.ApplicationLockLevel"], + authorizations: List["_models.ApplicationProviderAuthorization"], + location: Optional[str] = None, + tags: Optional[Dict[str, str]] = None, + managed_by: Optional[str] = None, + sku: Optional["_models.Sku"] = None, + identity: Optional["_models.Identity"] = None, + display_name: Optional[str] = None, + is_enabled: Optional[str] = None, + artifacts: Optional[List["_models.ApplicationArtifact"]] = None, + description: Optional[str] = None, + package_file_uri: Optional[str] = None, + main_template: Optional[Any] = None, + create_ui_definition: Optional[Any] = None, + **kwargs + ): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword managed_by: ID of the resource that manages this resource. + :paramtype managed_by: str + :keyword sku: The SKU of the resource. + :paramtype sku: ~azure.mgmt.managedapplication.v2017_12_01.models.Sku + :keyword identity: The identity of the resource. + :paramtype identity: ~azure.mgmt.managedapplication.v2017_12_01.models.Identity + :keyword lock_level: Required. The managed application lock level. Known values are: + "CanNotDelete", "ReadOnly", "None". + :paramtype lock_level: str or + ~azure.mgmt.managedapplication.v2017_12_01.models.ApplicationLockLevel + :keyword display_name: The managed application definition display name. + :paramtype display_name: str + :keyword is_enabled: A value indicating whether the package is enabled or not. + :paramtype is_enabled: str + :keyword authorizations: Required. The managed application provider authorizations. + :paramtype authorizations: + list[~azure.mgmt.managedapplication.v2017_12_01.models.ApplicationProviderAuthorization] + :keyword artifacts: The collection of managed application artifacts. The portal will use the + files specified as artifacts to construct the user experience of creating a managed application + from a managed application definition. + :paramtype artifacts: + list[~azure.mgmt.managedapplication.v2017_12_01.models.ApplicationArtifact] + :keyword description: The managed application definition description. + :paramtype description: str + :keyword package_file_uri: The managed application definition package file Uri. Use this + element. + :paramtype package_file_uri: str + :keyword main_template: The inline main template json which has resources to be provisioned. It + can be a JObject or well-formed JSON string. + :paramtype main_template: any + :keyword create_ui_definition: The createUiDefinition json for the backing template with + Microsoft.Solutions/applications resource. It can be a JObject or well-formed JSON string. + :paramtype create_ui_definition: any + """ + super(ApplicationDefinition, self).__init__(location=location, tags=tags, managed_by=managed_by, sku=sku, identity=identity, **kwargs) + self.lock_level = lock_level + self.display_name = display_name + self.is_enabled = is_enabled + self.authorizations = authorizations + self.artifacts = artifacts + self.description = description + self.package_file_uri = package_file_uri + self.main_template = main_template + self.create_ui_definition = create_ui_definition + + +class ApplicationDefinitionListResult(msrest.serialization.Model): + """List of managed application definitions. + + :ivar value: The array of managed application definitions. + :vartype value: list[~azure.mgmt.managedapplication.v2017_12_01.models.ApplicationDefinition] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[ApplicationDefinition]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["_models.ApplicationDefinition"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + """ + :keyword value: The array of managed application definitions. + :paramtype value: list[~azure.mgmt.managedapplication.v2017_12_01.models.ApplicationDefinition] + :keyword next_link: The URL to use for getting the next set of results. + :paramtype next_link: str + """ + super(ApplicationDefinitionListResult, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class ApplicationDefinitionPatchable(msrest.serialization.Model): + """Information about an application definition request. + + :ivar tags: A set of tags. Application definition tags. + :vartype tags: dict[str, str] + """ + + _attribute_map = { + 'tags': {'key': 'tags', 'type': '{str}'}, + } + + def __init__( + self, + *, + tags: Optional[Dict[str, str]] = None, + **kwargs + ): + """ + :keyword tags: A set of tags. Application definition tags. + :paramtype tags: dict[str, str] + """ + super(ApplicationDefinitionPatchable, self).__init__(**kwargs) + self.tags = tags + + +class ApplicationListResult(msrest.serialization.Model): + """List of managed applications. + + :ivar value: The array of managed applications. + :vartype value: list[~azure.mgmt.managedapplication.v2017_12_01.models.Application] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Application]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["_models.Application"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + """ + :keyword value: The array of managed applications. + :paramtype value: list[~azure.mgmt.managedapplication.v2017_12_01.models.Application] + :keyword next_link: The URL to use for getting the next set of results. + :paramtype next_link: str + """ + super(ApplicationListResult, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class ApplicationPatchable(GenericResource): + """Information about managed application. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Resource ID. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar location: Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar managed_by: ID of the resource that manages this resource. + :vartype managed_by: str + :ivar sku: The SKU of the resource. + :vartype sku: ~azure.mgmt.managedapplication.v2017_12_01.models.Sku + :ivar identity: The identity of the resource. + :vartype identity: ~azure.mgmt.managedapplication.v2017_12_01.models.Identity + :ivar plan: The plan information. + :vartype plan: ~azure.mgmt.managedapplication.v2017_12_01.models.PlanPatchable + :ivar kind: The kind of the managed application. Allowed values are MarketPlace and + ServiceCatalog. + :vartype kind: str + :ivar managed_resource_group_id: The managed resource group Id. + :vartype managed_resource_group_id: str + :ivar application_definition_id: The fully qualified path of managed application definition Id. + :vartype application_definition_id: str + :ivar parameters: Name and value pairs that define the managed application parameters. It can + be a JObject or a well formed JSON string. + :vartype parameters: any + :ivar outputs: Name and value pairs that define the managed application outputs. + :vartype outputs: any + :ivar provisioning_state: The managed application provisioning state. Known values are: + "Accepted", "Running", "Ready", "Creating", "Created", "Deleting", "Deleted", "Canceled", + "Failed", "Succeeded", "Updating". + :vartype provisioning_state: str or + ~azure.mgmt.managedapplication.v2017_12_01.models.ProvisioningState + :ivar ui_definition_uri: The blob URI where the UI definition file is located. + :vartype ui_definition_uri: str + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'kind': {'pattern': r'^[-\w\._,\(\)]+$'}, + 'outputs': {'readonly': True}, + 'provisioning_state': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'location': {'key': 'location', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + 'managed_by': {'key': 'managedBy', 'type': 'str'}, + 'sku': {'key': 'sku', 'type': 'Sku'}, + 'identity': {'key': 'identity', 'type': 'Identity'}, + 'plan': {'key': 'plan', 'type': 'PlanPatchable'}, + 'kind': {'key': 'kind', 'type': 'str'}, + 'managed_resource_group_id': {'key': 'properties.managedResourceGroupId', 'type': 'str'}, + 'application_definition_id': {'key': 'properties.applicationDefinitionId', 'type': 'str'}, + 'parameters': {'key': 'properties.parameters', 'type': 'object'}, + 'outputs': {'key': 'properties.outputs', 'type': 'object'}, + 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + 'ui_definition_uri': {'key': 'properties.uiDefinitionUri', 'type': 'str'}, + } + + def __init__( + self, + *, + location: Optional[str] = None, + tags: Optional[Dict[str, str]] = None, + managed_by: Optional[str] = None, + sku: Optional["_models.Sku"] = None, + identity: Optional["_models.Identity"] = None, + plan: Optional["_models.PlanPatchable"] = None, + kind: Optional[str] = None, + managed_resource_group_id: Optional[str] = None, + application_definition_id: Optional[str] = None, + parameters: Optional[Any] = None, + ui_definition_uri: Optional[str] = None, + **kwargs + ): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword managed_by: ID of the resource that manages this resource. + :paramtype managed_by: str + :keyword sku: The SKU of the resource. + :paramtype sku: ~azure.mgmt.managedapplication.v2017_12_01.models.Sku + :keyword identity: The identity of the resource. + :paramtype identity: ~azure.mgmt.managedapplication.v2017_12_01.models.Identity + :keyword plan: The plan information. + :paramtype plan: ~azure.mgmt.managedapplication.v2017_12_01.models.PlanPatchable + :keyword kind: The kind of the managed application. Allowed values are MarketPlace and + ServiceCatalog. + :paramtype kind: str + :keyword managed_resource_group_id: The managed resource group Id. + :paramtype managed_resource_group_id: str + :keyword application_definition_id: The fully qualified path of managed application definition + Id. + :paramtype application_definition_id: str + :keyword parameters: Name and value pairs that define the managed application parameters. It + can be a JObject or a well formed JSON string. + :paramtype parameters: any + :keyword ui_definition_uri: The blob URI where the UI definition file is located. + :paramtype ui_definition_uri: str + """ + super(ApplicationPatchable, self).__init__(location=location, tags=tags, managed_by=managed_by, sku=sku, identity=identity, **kwargs) + self.plan = plan + self.kind = kind + self.managed_resource_group_id = managed_resource_group_id + self.application_definition_id = application_definition_id + self.parameters = parameters + self.outputs = None + self.provisioning_state = None + self.ui_definition_uri = ui_definition_uri + + +class ApplicationProviderAuthorization(msrest.serialization.Model): + """The managed application provider authorization. + + All required parameters must be populated in order to send to Azure. + + :ivar principal_id: Required. The provider's principal identifier. This is the identity that + the provider will use to call ARM to manage the managed application resources. + :vartype principal_id: str + :ivar role_definition_id: Required. The provider's role definition identifier. This role will + define all the permissions that the provider must have on the managed application's container + resource group. This role definition cannot have permission to delete the resource group. + :vartype role_definition_id: str + """ + + _validation = { + 'principal_id': {'required': True}, + 'role_definition_id': {'required': True}, + } + + _attribute_map = { + 'principal_id': {'key': 'principalId', 'type': 'str'}, + 'role_definition_id': {'key': 'roleDefinitionId', 'type': 'str'}, + } + + def __init__( + self, + *, + principal_id: str, + role_definition_id: str, + **kwargs + ): + """ + :keyword principal_id: Required. The provider's principal identifier. This is the identity that + the provider will use to call ARM to manage the managed application resources. + :paramtype principal_id: str + :keyword role_definition_id: Required. The provider's role definition identifier. This role + will define all the permissions that the provider must have on the managed application's + container resource group. This role definition cannot have permission to delete the resource + group. + :paramtype role_definition_id: str + """ + super(ApplicationProviderAuthorization, self).__init__(**kwargs) + self.principal_id = principal_id + self.role_definition_id = role_definition_id + + +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.managedapplication.v2017_12_01.models.ErrorDetail] + :ivar additional_info: The error additional info. + :vartype additional_info: + list[~azure.mgmt.managedapplication.v2017_12_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.). + + :ivar error: The error object. + :vartype error: ~azure.mgmt.managedapplication.v2017_12_01.models.ErrorDetail + """ + + _attribute_map = { + 'error': {'key': 'error', 'type': 'ErrorDetail'}, + } + + def __init__( + self, + *, + error: Optional["_models.ErrorDetail"] = None, + **kwargs + ): + """ + :keyword error: The error object. + :paramtype error: ~azure.mgmt.managedapplication.v2017_12_01.models.ErrorDetail + """ + super(ErrorResponse, self).__init__(**kwargs) + self.error = error + + +class Identity(msrest.serialization.Model): + """Identity for the resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar principal_id: The principal ID of resource identity. + :vartype principal_id: str + :ivar tenant_id: The tenant ID of resource. + :vartype tenant_id: str + :ivar type: The identity type. The only acceptable values to pass in are None and + "SystemAssigned". The default value is None. + :vartype type: str + """ + + _validation = { + 'principal_id': {'readonly': True}, + 'tenant_id': {'readonly': True}, + } + + _attribute_map = { + 'principal_id': {'key': 'principalId', 'type': 'str'}, + 'tenant_id': {'key': 'tenantId', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + } + + def __init__( + self, + *, + type: Optional[str] = None, + **kwargs + ): + """ + :keyword type: The identity type. The only acceptable values to pass in are None and + "SystemAssigned". The default value is None. + :paramtype type: str + """ + super(Identity, self).__init__(**kwargs) + self.principal_id = None + self.tenant_id = None + self.type = type + + +class Operation(msrest.serialization.Model): + """Details of a REST API operation, returned from the Resource Provider Operations API. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name: The name of the operation, as per Resource-Based Access Control (RBAC). Examples: + "Microsoft.Compute/virtualMachines/write", "Microsoft.Compute/virtualMachines/capture/action". + :vartype name: str + :ivar is_data_action: Whether the operation applies to data-plane. This is "true" for + data-plane operations and "false" for ARM/control-plane operations. + :vartype is_data_action: bool + :ivar display: Localized display information for this particular operation. + :vartype display: ~azure.mgmt.managedapplication.v2017_12_01.models.OperationDisplay + :ivar origin: The intended executor of the operation; as in Resource Based Access Control + (RBAC) and audit logs UX. Default value is "user,system". Known values are: "user", "system", + "user,system". + :vartype origin: str or ~azure.mgmt.managedapplication.v2017_12_01.models.Origin + :ivar action_type: Enum. Indicates the action type. "Internal" refers to actions that are for + internal only APIs. Known values are: "Internal". + :vartype action_type: str or ~azure.mgmt.managedapplication.v2017_12_01.models.ActionType + """ + + _validation = { + 'name': {'readonly': True}, + 'is_data_action': {'readonly': True}, + 'origin': {'readonly': True}, + 'action_type': {'readonly': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'is_data_action': {'key': 'isDataAction', 'type': 'bool'}, + 'display': {'key': 'display', 'type': 'OperationDisplay'}, + 'origin': {'key': 'origin', 'type': 'str'}, + 'action_type': {'key': 'actionType', 'type': 'str'}, + } + + def __init__( + self, + *, + display: Optional["_models.OperationDisplay"] = None, + **kwargs + ): + """ + :keyword display: Localized display information for this particular operation. + :paramtype display: ~azure.mgmt.managedapplication.v2017_12_01.models.OperationDisplay + """ + super(Operation, self).__init__(**kwargs) + self.name = None + self.is_data_action = None + self.display = display + self.origin = None + self.action_type = None + + +class OperationDisplay(msrest.serialization.Model): + """Localized display information for this particular operation. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar provider: The localized friendly form of the resource provider name, e.g. "Microsoft + Monitoring Insights" or "Microsoft Compute". + :vartype provider: str + :ivar resource: The localized friendly name of the resource type related to this operation. + E.g. "Virtual Machines" or "Job Schedule Collections". + :vartype resource: str + :ivar operation: The concise, localized friendly name for the operation; suitable for + dropdowns. E.g. "Create or Update Virtual Machine", "Restart Virtual Machine". + :vartype operation: str + :ivar description: The short, localized friendly description of the operation; suitable for + tool tips and detailed views. + :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): + """A list of REST API operations supported by an Azure Resource Provider. It contains an URL link to get the next set of results. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: List of operations supported by the resource provider. + :vartype value: list[~azure.mgmt.managedapplication.v2017_12_01.models.Operation] + :ivar next_link: URL to get the next set of operation list results (if there are any). + :vartype next_link: str + """ + + _validation = { + 'value': {'readonly': True}, + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Operation]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(OperationListResult, self).__init__(**kwargs) + self.value = None + self.next_link = None + + +class Plan(msrest.serialization.Model): + """Plan for the managed application. + + All required parameters must be populated in order to send to Azure. + + :ivar name: Required. The plan name. + :vartype name: str + :ivar publisher: Required. The publisher ID. + :vartype publisher: str + :ivar product: Required. The product code. + :vartype product: str + :ivar promotion_code: The promotion code. + :vartype promotion_code: str + :ivar version: Required. The plan's version. + :vartype version: str + """ + + _validation = { + 'name': {'required': True}, + 'publisher': {'required': True}, + 'product': {'required': True}, + 'version': {'required': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'publisher': {'key': 'publisher', 'type': 'str'}, + 'product': {'key': 'product', 'type': 'str'}, + 'promotion_code': {'key': 'promotionCode', 'type': 'str'}, + 'version': {'key': 'version', 'type': 'str'}, + } + + def __init__( + self, + *, + name: str, + publisher: str, + product: str, + version: str, + promotion_code: Optional[str] = None, + **kwargs + ): + """ + :keyword name: Required. The plan name. + :paramtype name: str + :keyword publisher: Required. The publisher ID. + :paramtype publisher: str + :keyword product: Required. The product code. + :paramtype product: str + :keyword promotion_code: The promotion code. + :paramtype promotion_code: str + :keyword version: Required. The plan's version. + :paramtype version: str + """ + super(Plan, self).__init__(**kwargs) + self.name = name + self.publisher = publisher + self.product = product + self.promotion_code = promotion_code + self.version = version + + +class PlanPatchable(msrest.serialization.Model): + """Plan for the managed application. + + :ivar name: The plan name. + :vartype name: str + :ivar publisher: The publisher ID. + :vartype publisher: str + :ivar product: The product code. + :vartype product: str + :ivar promotion_code: The promotion code. + :vartype promotion_code: str + :ivar version: The plan's version. + :vartype version: str + """ + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'publisher': {'key': 'publisher', 'type': 'str'}, + 'product': {'key': 'product', 'type': 'str'}, + 'promotion_code': {'key': 'promotionCode', 'type': 'str'}, + 'version': {'key': 'version', 'type': 'str'}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + publisher: Optional[str] = None, + product: Optional[str] = None, + promotion_code: Optional[str] = None, + version: Optional[str] = None, + **kwargs + ): + """ + :keyword name: The plan name. + :paramtype name: str + :keyword publisher: The publisher ID. + :paramtype publisher: str + :keyword product: The product code. + :paramtype product: str + :keyword promotion_code: The promotion code. + :paramtype promotion_code: str + :keyword version: The plan's version. + :paramtype version: str + """ + super(PlanPatchable, self).__init__(**kwargs) + self.name = name + self.publisher = publisher + self.product = product + self.promotion_code = promotion_code + self.version = version + + +class Sku(msrest.serialization.Model): + """SKU for the resource. + + All required parameters must be populated in order to send to Azure. + + :ivar name: Required. The SKU name. + :vartype name: str + :ivar tier: The SKU tier. + :vartype tier: str + :ivar size: The SKU size. + :vartype size: str + :ivar family: The SKU family. + :vartype family: str + :ivar model: The SKU model. + :vartype model: str + :ivar capacity: The SKU capacity. + :vartype capacity: int + """ + + _validation = { + 'name': {'required': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'tier': {'key': 'tier', 'type': 'str'}, + 'size': {'key': 'size', 'type': 'str'}, + 'family': {'key': 'family', 'type': 'str'}, + 'model': {'key': 'model', 'type': 'str'}, + 'capacity': {'key': 'capacity', 'type': 'int'}, + } + + def __init__( + self, + *, + name: str, + tier: Optional[str] = None, + size: Optional[str] = None, + family: Optional[str] = None, + model: Optional[str] = None, + capacity: Optional[int] = None, + **kwargs + ): + """ + :keyword name: Required. The SKU name. + :paramtype name: str + :keyword tier: The SKU tier. + :paramtype tier: str + :keyword size: The SKU size. + :paramtype size: str + :keyword family: The SKU family. + :paramtype family: str + :keyword model: The SKU model. + :paramtype model: str + :keyword capacity: The SKU capacity. + :paramtype capacity: int + """ + super(Sku, self).__init__(**kwargs) + self.name = name + self.tier = tier + self.size = size + self.family = family + self.model = model + self.capacity = capacity diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_12_01/models/_patch.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_12_01/models/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_12_01/models/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_12_01/operations/__init__.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_12_01/operations/__init__.py new file mode 100644 index 000000000000..47d8f29e4b2c --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_12_01/operations/__init__.py @@ -0,0 +1,22 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._application_client_operations import ApplicationClientOperationsMixin +from ._applications_operations import ApplicationsOperations +from ._application_definitions_operations import ApplicationDefinitionsOperations + +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk +__all__ = [ + 'ApplicationClientOperationsMixin', + 'ApplicationsOperations', + 'ApplicationDefinitionsOperations', +] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_12_01/operations/_application_client_operations.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_12_01/operations/_application_client_operations.py new file mode 100644 index 000000000000..cc851eb8c2e2 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_12_01/operations/_application_client_operations.py @@ -0,0 +1,134 @@ +# 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.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._vendor import MixinABC, _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_operations_request( + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.Solutions/operations") + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + +class ApplicationClientOperationsMixin(MixinABC): + + @distributed_trace + def list_operations( + self, + **kwargs: Any + ) -> Iterable[_models.OperationListResult]: + """Lists all of the available Microsoft.Solutions REST API operations. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either OperationListResult or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.managedapplication.v2017_12_01.models.OperationListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # 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', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_operations_request( + api_version=api_version, + template_url=self.list_operations.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_operations_request( + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list_operations.metadata = {'url': "/providers/Microsoft.Solutions/operations"} # type: ignore diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_12_01/operations/_application_definitions_operations.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_12_01/operations/_application_definitions_operations.py new file mode 100644 index 000000000000..e29352302544 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_12_01/operations/_application_definitions_operations.py @@ -0,0 +1,720 @@ +# 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.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._vendor import MixinABC, _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_request( + resource_group_name: str, + application_definition_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "applicationDefinitionName": _SERIALIZER.url("application_definition_name", application_definition_name, 'str', max_length=64, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_delete_request( + resource_group_name: str, + application_definition_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "applicationDefinitionName": _SERIALIZER.url("application_definition_name", application_definition_name, 'str', max_length=64, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_create_or_update_request( + resource_group_name: str, + application_definition_name: str, + subscription_id: str, + *, + json: Optional[_models.ApplicationDefinition] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "applicationDefinitionName": _SERIALIZER.url("application_definition_name", application_definition_name, 'str', max_length=64, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_update_request( + subscription_id: str, + resource_group_name: str, + application_definition_name: str, + *, + json: Optional[_models.ApplicationDefinitionPatchable] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "applicationDefinitionName": _SERIALIZER.url("application_definition_name", application_definition_name, 'str', max_length=64, min_length=3), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_list_by_resource_group_request( + resource_group_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_list_by_subscription_request( + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Solutions/applicationDefinitions") + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + +class ApplicationDefinitionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.managedapplication.v2017_12_01.ApplicationClient`'s + :attr:`application_definitions` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + + @distributed_trace + def get( + self, + resource_group_name: str, + application_definition_name: str, + **kwargs: Any + ) -> Optional[_models.ApplicationDefinition]: + """Gets the managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. + :type application_definition_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ApplicationDefinition, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2017_12_01.models.ApplicationDefinition or None + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.ApplicationDefinition]] + + + request = build_get_request( + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('ApplicationDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore + + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + application_definition_name: str, + **kwargs: Any + ) -> None: + """Deletes the managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition to delete. + :type application_definition_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_request( + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore + + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + application_definition_name: str, + parameters: _models.ApplicationDefinition, + **kwargs: Any + ) -> _models.ApplicationDefinition: + """Creates or updates a managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. + :type application_definition_name: str + :param parameters: Parameters supplied to the create or update an managed application + definition. + :type parameters: ~azure.mgmt.managedapplication.v2017_12_01.models.ApplicationDefinition + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ApplicationDefinition, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2017_12_01.models.ApplicationDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationDefinition] + + _json = self._serialize.body(parameters, 'ApplicationDefinition') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # 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, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('ApplicationDefinition', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('ApplicationDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore + + + @distributed_trace + def update( + self, + resource_group_name: str, + application_definition_name: str, + parameters: _models.ApplicationDefinitionPatchable, + **kwargs: Any + ) -> _models.ApplicationDefinition: + """Updates the managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. + :type application_definition_name: str + :param parameters: Parameters supplied to the update a managed application definition. + :type parameters: + ~azure.mgmt.managedapplication.v2017_12_01.models.ApplicationDefinitionPatchable + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ApplicationDefinition, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2017_12_01.models.ApplicationDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationDefinition] + + _json = self._serialize.body(parameters, 'ApplicationDefinitionPatchable') + + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ApplicationDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore + + + @distributed_trace + def list_by_resource_group( + self, + resource_group_name: str, + **kwargs: Any + ) -> Iterable[_models.ApplicationDefinitionListResult]: + """Lists the managed application definitions in a resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ApplicationDefinitionListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.managedapplication.v2017_12_01.models.ApplicationDefinitionListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationDefinitionListResult] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_resource_group.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ApplicationDefinitionListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions"} # type: ignore + + @distributed_trace + def list_by_subscription( + self, + **kwargs: Any + ) -> Iterable[_models.ApplicationDefinitionListResult]: + """Lists the managed application definitions in a subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ApplicationDefinitionListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.managedapplication.v2017_12_01.models.ApplicationDefinitionListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationDefinitionListResult] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ApplicationDefinitionListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Solutions/applicationDefinitions"} # type: ignore diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_12_01/operations/_applications_operations.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_12_01/operations/_applications_operations.py new file mode 100644 index 000000000000..80533e2ec97c --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_12_01/operations/_applications_operations.py @@ -0,0 +1,1530 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast + +from msrest import Serializer + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from .._vendor import MixinABC, _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_request( + resource_group_name: str, + application_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "applicationName": _SERIALIZER.url("application_name", application_name, 'str', max_length=64, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_delete_request_initial( + resource_group_name: str, + application_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "applicationName": _SERIALIZER.url("application_name", application_name, 'str', max_length=64, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_create_or_update_request_initial( + resource_group_name: str, + application_name: str, + subscription_id: str, + *, + json: Optional[_models.Application] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "applicationName": _SERIALIZER.url("application_name", application_name, 'str', max_length=64, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_update_request_initial( + resource_group_name: str, + application_name: str, + subscription_id: str, + *, + json: Optional[_models.ApplicationPatchable] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "applicationName": _SERIALIZER.url("application_name", application_name, 'str', max_length=64, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_list_by_resource_group_request( + resource_group_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_list_by_subscription_request( + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Solutions/applications") + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_get_by_id_request( + application_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/{applicationId}") + path_format_arguments = { + "applicationId": _SERIALIZER.url("application_id", application_id, 'str', skip_quote=True), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_delete_by_id_request_initial( + application_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/{applicationId}") + path_format_arguments = { + "applicationId": _SERIALIZER.url("application_id", application_id, 'str', skip_quote=True), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_create_or_update_by_id_request_initial( + application_id: str, + *, + json: Optional[_models.Application] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/{applicationId}") + path_format_arguments = { + "applicationId": _SERIALIZER.url("application_id", application_id, 'str', skip_quote=True), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_update_by_id_request_initial( + application_id: str, + *, + json: Optional[_models.ApplicationPatchable] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/{applicationId}") + path_format_arguments = { + "applicationId": _SERIALIZER.url("application_id", application_id, 'str', skip_quote=True), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + +class ApplicationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.managedapplication.v2017_12_01.ApplicationClient`'s + :attr:`applications` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + + @distributed_trace + def get( + self, + resource_group_name: str, + application_name: str, + **kwargs: Any + ) -> Optional[_models.Application]: + """Gets the managed application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_name: The name of the managed application. + :type application_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Application, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2017_12_01.models.Application or None + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.Application]] + + + request = build_get_request( + resource_group_name=resource_group_name, + application_name=application_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('Application', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}"} # type: ignore + + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + application_name: str, + **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + application_name=application_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}"} # type: ignore + + + @distributed_trace + def begin_delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + application_name: str, + **kwargs: Any + ) -> LROPoller[None]: + """Deletes the managed application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_name: The name of the managed application. + :type application_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._delete_initial( # type: ignore + resource_group_name=resource_group_name, + application_name=application_name, + api_version=api_version, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}"} # type: ignore + + def _create_or_update_initial( + self, + resource_group_name: str, + application_name: str, + parameters: _models.Application, + **kwargs: Any + ) -> _models.Application: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Application] + + _json = self._serialize.body(parameters, 'Application') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + application_name=application_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('Application', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('Application', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}"} # type: ignore + + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + application_name: str, + parameters: _models.Application, + **kwargs: Any + ) -> LROPoller[_models.Application]: + """Creates or updates a managed application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_name: The name of the managed application. + :type application_name: str + :param parameters: Parameters supplied to the create or update a managed application. + :type parameters: ~azure.mgmt.managedapplication.v2017_12_01.models.Application + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Application or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.managedapplication.v2017_12_01.models.Application] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Application] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._create_or_update_initial( # type: ignore + resource_group_name=resource_group_name, + application_name=application_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('Application', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}"} # type: ignore + + def _update_initial( + self, + resource_group_name: str, + application_name: str, + parameters: Optional[_models.ApplicationPatchable] = None, + **kwargs: Any + ) -> _models.ApplicationPatchable: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationPatchable] + + if parameters is not None: + _json = self._serialize.body(parameters, 'ApplicationPatchable') + else: + _json = None + + request = build_update_request_initial( + resource_group_name=resource_group_name, + application_name=application_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('ApplicationPatchable', pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize('ApplicationPatchable', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}"} # type: ignore + + + @distributed_trace + def begin_update( + self, + resource_group_name: str, + application_name: str, + parameters: Optional[_models.ApplicationPatchable] = None, + **kwargs: Any + ) -> LROPoller[_models.ApplicationPatchable]: + """Updates an existing managed application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_name: The name of the managed application. + :type application_name: str + :param parameters: Parameters supplied to update an existing managed application. Default value + is None. + :type parameters: ~azure.mgmt.managedapplication.v2017_12_01.models.ApplicationPatchable + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ApplicationPatchable or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.managedapplication.v2017_12_01.models.ApplicationPatchable] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationPatchable] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._update_initial( # type: ignore + resource_group_name=resource_group_name, + application_name=application_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('ApplicationPatchable', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}"} # type: ignore + + @distributed_trace + def list_by_resource_group( + self, + resource_group_name: str, + **kwargs: Any + ) -> Iterable[_models.ApplicationListResult]: + """Lists all the applications within a resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ApplicationListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.managedapplication.v2017_12_01.models.ApplicationListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationListResult] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_resource_group.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ApplicationListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications"} # type: ignore + + @distributed_trace + def list_by_subscription( + self, + **kwargs: Any + ) -> Iterable[_models.ApplicationListResult]: + """Gets all the applications within a subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ApplicationListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.managedapplication.v2017_12_01.models.ApplicationListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationListResult] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ApplicationListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Solutions/applications"} # type: ignore + + @distributed_trace + def get_by_id( + self, + application_id: str, + **kwargs: Any + ) -> Optional[_models.Application]: + """Gets the managed application. + + :param application_id: The fully qualified ID of the managed application, including the managed + application name and the managed application resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/Microsoft.Solutions/applications/{application-name}. + :type application_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Application, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2017_12_01.models.Application or None + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.Application]] + + + request = build_get_by_id_request( + application_id=application_id, + api_version=api_version, + template_url=self.get_by_id.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('Application', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_by_id.metadata = {'url': "/{applicationId}"} # type: ignore + + + def _delete_by_id_initial( # pylint: disable=inconsistent-return-statements + self, + application_id: str, + **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_by_id_request_initial( + application_id=application_id, + api_version=api_version, + template_url=self._delete_by_id_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_by_id_initial.metadata = {'url': "/{applicationId}"} # type: ignore + + + @distributed_trace + def begin_delete_by_id( # pylint: disable=inconsistent-return-statements + self, + application_id: str, + **kwargs: Any + ) -> LROPoller[None]: + """Deletes the managed application. + + :param application_id: The fully qualified ID of the managed application, including the managed + application name and the managed application resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/Microsoft.Solutions/applications/{application-name}. + :type application_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._delete_by_id_initial( # type: ignore + application_id=application_id, + api_version=api_version, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete_by_id.metadata = {'url': "/{applicationId}"} # type: ignore + + def _create_or_update_by_id_initial( + self, + application_id: str, + parameters: _models.Application, + **kwargs: Any + ) -> _models.Application: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Application] + + _json = self._serialize.body(parameters, 'Application') + + request = build_create_or_update_by_id_request_initial( + application_id=application_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._create_or_update_by_id_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('Application', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('Application', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_by_id_initial.metadata = {'url': "/{applicationId}"} # type: ignore + + + @distributed_trace + def begin_create_or_update_by_id( + self, + application_id: str, + parameters: _models.Application, + **kwargs: Any + ) -> LROPoller[_models.Application]: + """Creates or updates a managed application. + + :param application_id: The fully qualified ID of the managed application, including the managed + application name and the managed application resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/Microsoft.Solutions/applications/{application-name}. + :type application_id: str + :param parameters: Parameters supplied to the create or update a managed application. + :type parameters: ~azure.mgmt.managedapplication.v2017_12_01.models.Application + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Application or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.managedapplication.v2017_12_01.models.Application] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Application] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._create_or_update_by_id_initial( # type: ignore + application_id=application_id, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('Application', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update_by_id.metadata = {'url': "/{applicationId}"} # type: ignore + + def _update_by_id_initial( + self, + application_id: str, + parameters: Optional[_models.ApplicationPatchable] = None, + **kwargs: Any + ) -> _models.ApplicationPatchable: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationPatchable] + + if parameters is not None: + _json = self._serialize.body(parameters, 'ApplicationPatchable') + else: + _json = None + + request = build_update_by_id_request_initial( + application_id=application_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._update_by_id_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('ApplicationPatchable', pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize('ApplicationPatchable', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _update_by_id_initial.metadata = {'url': "/{applicationId}"} # type: ignore + + + @distributed_trace + def begin_update_by_id( + self, + application_id: str, + parameters: Optional[_models.ApplicationPatchable] = None, + **kwargs: Any + ) -> LROPoller[_models.ApplicationPatchable]: + """Updates an existing managed application. + + :param application_id: The fully qualified ID of the managed application, including the managed + application name and the managed application resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/Microsoft.Solutions/applications/{application-name}. + :type application_id: str + :param parameters: Parameters supplied to update an existing managed application. Default value + is None. + :type parameters: ~azure.mgmt.managedapplication.v2017_12_01.models.ApplicationPatchable + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ApplicationPatchable or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.managedapplication.v2017_12_01.models.ApplicationPatchable] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationPatchable] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._update_by_id_initial( # type: ignore + application_id=application_id, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('ApplicationPatchable', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_update_by_id.metadata = {'url': "/{applicationId}"} # type: ignore diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_12_01/operations/_patch.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_12_01/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_12_01/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_12_01/py.typed b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_12_01/py.typed new file mode 100644 index 000000000000..e5aff4f83af8 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2017_12_01/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_02_01/__init__.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_02_01/__init__.py new file mode 100644 index 000000000000..2e61ca12e56a --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_02_01/__init__.py @@ -0,0 +1,23 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._application_client import ApplicationClient +from ._version import VERSION + +__version__ = VERSION + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk +__all__ = ['ApplicationClient'] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_02_01/_application_client.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_02_01/_application_client.py new file mode 100644 index 000000000000..2a77999e2555 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_02_01/_application_client.py @@ -0,0 +1,106 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from 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 ApplicationClientConfiguration +from .operations import ApplicationClientOperationsMixin, ApplicationDefinitionsOperations, ApplicationsOperations + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential + +class ApplicationClient(ApplicationClientOperationsMixin): + """ARM applications. + + :ivar applications: ApplicationsOperations operations + :vartype applications: + azure.mgmt.managedapplication.v2018_02_01.operations.ApplicationsOperations + :ivar application_definitions: ApplicationDefinitionsOperations operations + :vartype application_definitions: + azure.mgmt.managedapplication.v2018_02_01.operations.ApplicationDefinitionsOperations + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials.TokenCredential + :param subscription_id: The ID of the target subscription. + :type subscription_id: str + :param base_url: Service URL. Default value is "https://management.azure.com". + :type base_url: str + :keyword api_version: Api Version. Default value is "2018-02-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + """ + + def __init__( + self, + credential: "TokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = ApplicationClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.applications = ApplicationsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.application_definitions = ApplicationDefinitionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + + + 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: () -> ApplicationClient + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (Any) -> None + self._client.__exit__(*exc_details) diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_02_01/_configuration.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_02_01/_configuration.py new file mode 100644 index 000000000000..f5c486eb437c --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_02_01/_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 ApplicationClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes + """Configuration for ApplicationClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials.TokenCredential + :param subscription_id: The ID of the target subscription. + :type subscription_id: str + :keyword api_version: Api Version. Default value is "2018-02-01". 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(ApplicationClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2018-02-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.") + + 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-managedapplication/{}'.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/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_02_01/_metadata.json b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_02_01/_metadata.json new file mode 100644 index 000000000000..83e0b1c5e3cd --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_02_01/_metadata.json @@ -0,0 +1,122 @@ +{ + "chosen_version": "2018-02-01", + "total_api_version_list": ["2018-02-01"], + "client": { + "name": "ApplicationClient", + "filename": "_application_client", + "description": "ARM applications.", + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": null, + "azure_arm": true, + "has_lro_operations": true, + "client_side_validation": false, + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ApplicationClientConfiguration\"], \"._operations_mixin\": [\"ApplicationClientOperationsMixin\"]}, \"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\": [\"ApplicationClientConfiguration\"], \"._operations_mixin\": [\"ApplicationClientOperationsMixin\"]}, \"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": { + "applications": "ApplicationsOperations", + "application_definitions": "ApplicationDefinitionsOperations" + }, + "operation_mixins": { + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Iterable\"]}, \"azurecore\": {\"azure.core.paging\": [\"ItemPaged\"]}}, \"regular\": {\"local\": {\".\": [[\"models\", \"_models\"]]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"AsyncIterable\"]}, \"azurecore\": {\"azure.core.async_paging\": [\"AsyncItemPaged\"]}}, \"regular\": {\"local\": {\"..\": [[\"models\", \"_models\"]]}}}", + "operations": { + "list_operations" : { + "sync": { + "signature": "def list_operations(\n self,\n **kwargs # type: Any\n):\n # type: (...) -\u003e Iterable[_models.OperationListResult]\n", + "doc": "\"\"\"Lists all of the available Microsoft.Solutions REST API operations.\n\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: An iterator like instance of either OperationListResult or the result of cls(response)\n:rtype:\n ~azure.core.paging.ItemPaged[~azure.mgmt.managedapplication.v2018_02_01.models.OperationListResult]\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"", + "call": "**kwargs" + }, + "async": { + "coroutine": false, + "signature": "def list_operations(\n self,\n **kwargs: Any\n) -\u003e AsyncIterable[_models.OperationListResult]:\n", + "doc": "\"\"\"Lists all of the available Microsoft.Solutions REST API operations.\n\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: An iterator like instance of either OperationListResult or the result of cls(response)\n:rtype:\n ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.managedapplication.v2018_02_01.models.OperationListResult]\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"", + "call": "**kwargs" + } + } + } + } +} \ No newline at end of file diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_02_01/_patch.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_02_01/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_02_01/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_02_01/_vendor.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_02_01/_vendor.py new file mode 100644 index 000000000000..bf1845cabc0f --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_02_01/_vendor.py @@ -0,0 +1,45 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from abc import ABC +from typing import TYPE_CHECKING + +from azure.core.pipeline.transport import HttpRequest + +from ._configuration import ApplicationClientConfiguration + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from msrest import Deserializer, Serializer + + from azure.core import PipelineClient + +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) + +class MixinABC(ABC): + """DO NOT use this class. It is for internal typing use only.""" + _client: "PipelineClient" + _config: ApplicationClientConfiguration + _serialize: "Serializer" + _deserialize: "Deserializer" diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_02_01/_version.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_02_01/_version.py new file mode 100644 index 000000000000..e5754a47ce68 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_02_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/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_02_01/aio/__init__.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_02_01/aio/__init__.py new file mode 100644 index 000000000000..c90626a31421 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_02_01/aio/__init__.py @@ -0,0 +1,20 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._application_client import ApplicationClient + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk +__all__ = ['ApplicationClient'] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_02_01/aio/_application_client.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_02_01/aio/_application_client.py new file mode 100644 index 000000000000..f606769052fb --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_02_01/aio/_application_client.py @@ -0,0 +1,103 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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 ApplicationClientConfiguration +from .operations import ApplicationClientOperationsMixin, ApplicationDefinitionsOperations, ApplicationsOperations + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + +class ApplicationClient(ApplicationClientOperationsMixin): + """ARM applications. + + :ivar applications: ApplicationsOperations operations + :vartype applications: + azure.mgmt.managedapplication.v2018_02_01.aio.operations.ApplicationsOperations + :ivar application_definitions: ApplicationDefinitionsOperations operations + :vartype application_definitions: + azure.mgmt.managedapplication.v2018_02_01.aio.operations.ApplicationDefinitionsOperations + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :param subscription_id: The ID of the target subscription. + :type subscription_id: str + :param base_url: Service URL. Default value is "https://management.azure.com". + :type base_url: str + :keyword api_version: Api Version. Default value is "2018-02-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = ApplicationClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.applications = ApplicationsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.application_definitions = ApplicationDefinitionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + + + 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) -> "ApplicationClient": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_02_01/aio/_configuration.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_02_01/aio/_configuration.py new file mode 100644 index 000000000000..ad85f0ca4a58 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_02_01/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 ApplicationClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes + """Configuration for ApplicationClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :param subscription_id: The ID of the target subscription. + :type subscription_id: str + :keyword api_version: Api Version. Default value is "2018-02-01". 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(ApplicationClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2018-02-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.") + + 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-managedapplication/{}'.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/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_02_01/aio/_patch.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_02_01/aio/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_02_01/aio/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_02_01/aio/_vendor.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_02_01/aio/_vendor.py new file mode 100644 index 000000000000..da14e4f71f0e --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_02_01/aio/_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 abc import ABC +from typing import TYPE_CHECKING + +from azure.core.pipeline.transport import HttpRequest + +from ._configuration import ApplicationClientConfiguration + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from msrest import Deserializer, Serializer + + from azure.core import AsyncPipelineClient + + +class MixinABC(ABC): + """DO NOT use this class. It is for internal typing use only.""" + _client: "AsyncPipelineClient" + _config: ApplicationClientConfiguration + _serialize: "Serializer" + _deserialize: "Deserializer" diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_02_01/aio/operations/__init__.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_02_01/aio/operations/__init__.py new file mode 100644 index 000000000000..47d8f29e4b2c --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_02_01/aio/operations/__init__.py @@ -0,0 +1,22 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._application_client_operations import ApplicationClientOperationsMixin +from ._applications_operations import ApplicationsOperations +from ._application_definitions_operations import ApplicationDefinitionsOperations + +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk +__all__ = [ + 'ApplicationClientOperationsMixin', + 'ApplicationsOperations', + 'ApplicationDefinitionsOperations', +] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_02_01/aio/operations/_application_client_operations.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_02_01/aio/operations/_application_client_operations.py new file mode 100644 index 000000000000..57f4aac816b0 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_02_01/aio/operations/_application_client_operations.py @@ -0,0 +1,105 @@ +# 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.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._application_client_operations import build_list_operations_request +from .._vendor import MixinABC +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class ApplicationClientOperationsMixin(MixinABC): + + @distributed_trace + def list_operations( + self, + **kwargs: Any + ) -> AsyncIterable[_models.OperationListResult]: + """Lists all of the available Microsoft.Solutions REST API operations. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either OperationListResult or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.managedapplication.v2018_02_01.models.OperationListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # 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', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_operations_request( + api_version=api_version, + template_url=self.list_operations.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_operations_request( + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list_operations.metadata = {'url': "/providers/Microsoft.Solutions/operations"} # type: ignore diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_02_01/aio/operations/_application_definitions_operations.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_02_01/aio/operations/_application_definitions_operations.py new file mode 100644 index 000000000000..8293e56682ea --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_02_01/aio/operations/_application_definitions_operations.py @@ -0,0 +1,761 @@ +# 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.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._application_definitions_operations import build_create_or_update_by_id_request, build_create_or_update_request, build_delete_by_id_request, build_delete_request, build_get_by_id_request, build_get_request, build_list_by_resource_group_request, build_list_by_subscription_request, build_update_by_id_request, build_update_request +from .._vendor import MixinABC +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class ApplicationDefinitionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.managedapplication.v2018_02_01.aio.ApplicationClient`'s + :attr:`application_definitions` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + application_definition_name: str, + **kwargs: Any + ) -> Optional[_models.ApplicationDefinition]: + """Gets the managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. + :type application_definition_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ApplicationDefinition, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2018_02_01.models.ApplicationDefinition or None + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.ApplicationDefinition]] + + + request = build_get_request( + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('ApplicationDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore + + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + application_definition_name: str, + **kwargs: Any + ) -> None: + """Deletes the managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition to delete. + :type application_definition_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_request( + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore + + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + application_definition_name: str, + parameters: _models.ApplicationDefinition, + **kwargs: Any + ) -> _models.ApplicationDefinition: + """Creates or updates a managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. + :type application_definition_name: str + :param parameters: Parameters supplied to the create or update an managed application + definition. + :type parameters: ~azure.mgmt.managedapplication.v2018_02_01.models.ApplicationDefinition + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ApplicationDefinition, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2018_02_01.models.ApplicationDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationDefinition] + + _json = self._serialize.body(parameters, 'ApplicationDefinition') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # 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, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('ApplicationDefinition', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('ApplicationDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore + + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + application_definition_name: str, + parameters: _models.ApplicationDefinitionPatchable, + **kwargs: Any + ) -> _models.ApplicationDefinition: + """Updates the managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. + :type application_definition_name: str + :param parameters: Parameters supplied to the update a managed application definition. + :type parameters: + ~azure.mgmt.managedapplication.v2018_02_01.models.ApplicationDefinitionPatchable + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ApplicationDefinition, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2018_02_01.models.ApplicationDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationDefinition] + + _json = self._serialize.body(parameters, 'ApplicationDefinitionPatchable') + + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ApplicationDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore + + + @distributed_trace + def list_by_resource_group( + self, + resource_group_name: str, + **kwargs: Any + ) -> AsyncIterable[_models.ApplicationDefinitionListResult]: + """Lists the managed application definitions in a resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ApplicationDefinitionListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.managedapplication.v2018_02_01.models.ApplicationDefinitionListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationDefinitionListResult] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_resource_group.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ApplicationDefinitionListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions"} # type: ignore + + @distributed_trace + def list_by_subscription( + self, + **kwargs: Any + ) -> AsyncIterable[_models.ApplicationDefinitionListResult]: + """Lists the managed application definitions in a subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ApplicationDefinitionListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.managedapplication.v2018_02_01.models.ApplicationDefinitionListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationDefinitionListResult] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ApplicationDefinitionListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Solutions/applicationDefinitions"} # type: ignore + + @distributed_trace_async + async def get_by_id( + self, + resource_group_name: str, + application_definition_name: str, + **kwargs: Any + ) -> Optional[_models.ApplicationDefinition]: + """Gets the managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. + :type application_definition_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ApplicationDefinition, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2018_02_01.models.ApplicationDefinition or None + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.ApplicationDefinition]] + + + request = build_get_by_id_request( + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_by_id.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('ApplicationDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_by_id.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore + + + @distributed_trace_async + async def delete_by_id( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + application_definition_name: str, + **kwargs: Any + ) -> None: + """Deletes the managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. + :type application_definition_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_by_id_request( + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete_by_id.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete_by_id.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore + + + @distributed_trace_async + async def create_or_update_by_id( + self, + resource_group_name: str, + application_definition_name: str, + parameters: _models.ApplicationDefinition, + **kwargs: Any + ) -> _models.ApplicationDefinition: + """Creates or updates a managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. + :type application_definition_name: str + :param parameters: Parameters supplied to the create or update a managed application + definition. + :type parameters: ~azure.mgmt.managedapplication.v2018_02_01.models.ApplicationDefinition + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ApplicationDefinition, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2018_02_01.models.ApplicationDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationDefinition] + + _json = self._serialize.body(parameters, 'ApplicationDefinition') + + request = build_create_or_update_by_id_request( + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + 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'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # 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, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('ApplicationDefinition', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('ApplicationDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_or_update_by_id.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore + + + @distributed_trace_async + async def update_by_id( + self, + resource_group_name: str, + application_definition_name: str, + parameters: _models.ApplicationDefinitionPatchable, + **kwargs: Any + ) -> _models.ApplicationDefinition: + """Updates the managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. + :type application_definition_name: str + :param parameters: Parameters supplied to the update a managed application definition. + :type parameters: + ~azure.mgmt.managedapplication.v2018_02_01.models.ApplicationDefinitionPatchable + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ApplicationDefinition, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2018_02_01.models.ApplicationDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationDefinition] + + _json = self._serialize.body(parameters, 'ApplicationDefinitionPatchable') + + request = build_update_by_id_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.update_by_id.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ApplicationDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + update_by_id.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore + diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_02_01/aio/operations/_applications_operations.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_02_01/aio/operations/_applications_operations.py new file mode 100644 index 000000000000..20ee851f9e07 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_02_01/aio/operations/_applications_operations.py @@ -0,0 +1,1269 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union, cast + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._applications_operations import build_create_or_update_by_id_request_initial, build_create_or_update_request_initial, build_delete_by_id_request_initial, build_delete_request_initial, build_get_by_id_request, build_get_request, build_list_by_resource_group_request, build_list_by_subscription_request, build_refresh_permissions_request_initial, build_update_by_id_request_initial, build_update_request_initial +from .._vendor import MixinABC +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class ApplicationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.managedapplication.v2018_02_01.aio.ApplicationClient`'s + :attr:`applications` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + application_name: str, + **kwargs: Any + ) -> Optional[_models.Application]: + """Gets the managed application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_name: The name of the managed application. + :type application_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Application, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2018_02_01.models.Application or None + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.Application]] + + + request = build_get_request( + resource_group_name=resource_group_name, + application_name=application_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('Application', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}"} # type: ignore + + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + application_name: str, + **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + application_name=application_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}"} # type: ignore + + + @distributed_trace_async + async def begin_delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + application_name: str, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes the managed application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_name: The name of the managed application. + :type application_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._delete_initial( # type: ignore + resource_group_name=resource_group_name, + application_name=application_name, + api_version=api_version, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}"} # type: ignore + + async def _create_or_update_initial( + self, + resource_group_name: str, + application_name: str, + parameters: _models.Application, + **kwargs: Any + ) -> _models.Application: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Application] + + _json = self._serialize.body(parameters, 'Application') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + application_name=application_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('Application', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('Application', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}"} # type: ignore + + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + application_name: str, + parameters: _models.Application, + **kwargs: Any + ) -> AsyncLROPoller[_models.Application]: + """Creates or updates a managed application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_name: The name of the managed application. + :type application_name: str + :param parameters: Parameters supplied to the create or update a managed application. + :type parameters: ~azure.mgmt.managedapplication.v2018_02_01.models.Application + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either Application or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.managedapplication.v2018_02_01.models.Application] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Application] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._create_or_update_initial( # type: ignore + resource_group_name=resource_group_name, + application_name=application_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('Application', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}"} # type: ignore + + async def _update_initial( + self, + resource_group_name: str, + application_name: str, + parameters: Optional[_models.ApplicationPatchable] = None, + **kwargs: Any + ) -> _models.ApplicationPatchable: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationPatchable] + + if parameters is not None: + _json = self._serialize.body(parameters, 'ApplicationPatchable') + else: + _json = None + + request = build_update_request_initial( + resource_group_name=resource_group_name, + application_name=application_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('ApplicationPatchable', pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize('ApplicationPatchable', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}"} # type: ignore + + + @distributed_trace_async + async def begin_update( + self, + resource_group_name: str, + application_name: str, + parameters: Optional[_models.ApplicationPatchable] = None, + **kwargs: Any + ) -> AsyncLROPoller[_models.ApplicationPatchable]: + """Updates an existing managed application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_name: The name of the managed application. + :type application_name: str + :param parameters: Parameters supplied to update an existing managed application. Default value + is None. + :type parameters: ~azure.mgmt.managedapplication.v2018_02_01.models.ApplicationPatchable + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ApplicationPatchable or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.managedapplication.v2018_02_01.models.ApplicationPatchable] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationPatchable] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._update_initial( # type: ignore + resource_group_name=resource_group_name, + application_name=application_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('ApplicationPatchable', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}"} # type: ignore + + @distributed_trace + def list_by_resource_group( + self, + resource_group_name: str, + **kwargs: Any + ) -> AsyncIterable[_models.ApplicationListResult]: + """Lists all the applications within a resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ApplicationListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.managedapplication.v2018_02_01.models.ApplicationListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationListResult] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_resource_group.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ApplicationListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications"} # type: ignore + + @distributed_trace + def list_by_subscription( + self, + **kwargs: Any + ) -> AsyncIterable[_models.ApplicationListResult]: + """Lists all the applications within a subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ApplicationListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.managedapplication.v2018_02_01.models.ApplicationListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationListResult] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ApplicationListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Solutions/applications"} # type: ignore + + @distributed_trace_async + async def get_by_id( + self, + application_id: str, + **kwargs: Any + ) -> Optional[_models.Application]: + """Gets the managed application. + + :param application_id: The fully qualified ID of the managed application, including the managed + application name and the managed application resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/Microsoft.Solutions/applications/{application-name}. + :type application_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Application, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2018_02_01.models.Application or None + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.Application]] + + + request = build_get_by_id_request( + application_id=application_id, + api_version=api_version, + template_url=self.get_by_id.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('Application', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_by_id.metadata = {'url': "/{applicationId}"} # type: ignore + + + async def _delete_by_id_initial( # pylint: disable=inconsistent-return-statements + self, + application_id: str, + **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_by_id_request_initial( + application_id=application_id, + api_version=api_version, + template_url=self._delete_by_id_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_by_id_initial.metadata = {'url': "/{applicationId}"} # type: ignore + + + @distributed_trace_async + async def begin_delete_by_id( # pylint: disable=inconsistent-return-statements + self, + application_id: str, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes the managed application. + + :param application_id: The fully qualified ID of the managed application, including the managed + application name and the managed application resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/Microsoft.Solutions/applications/{application-name}. + :type application_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._delete_by_id_initial( # type: ignore + application_id=application_id, + api_version=api_version, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete_by_id.metadata = {'url': "/{applicationId}"} # type: ignore + + async def _create_or_update_by_id_initial( + self, + application_id: str, + parameters: _models.Application, + **kwargs: Any + ) -> _models.Application: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Application] + + _json = self._serialize.body(parameters, 'Application') + + request = build_create_or_update_by_id_request_initial( + application_id=application_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._create_or_update_by_id_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('Application', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('Application', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_by_id_initial.metadata = {'url': "/{applicationId}"} # type: ignore + + + @distributed_trace_async + async def begin_create_or_update_by_id( + self, + application_id: str, + parameters: _models.Application, + **kwargs: Any + ) -> AsyncLROPoller[_models.Application]: + """Creates or updates a managed application. + + :param application_id: The fully qualified ID of the managed application, including the managed + application name and the managed application resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/Microsoft.Solutions/applications/{application-name}. + :type application_id: str + :param parameters: Parameters supplied to the create or update a managed application. + :type parameters: ~azure.mgmt.managedapplication.v2018_02_01.models.Application + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either Application or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.managedapplication.v2018_02_01.models.Application] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Application] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._create_or_update_by_id_initial( # type: ignore + application_id=application_id, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('Application', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update_by_id.metadata = {'url': "/{applicationId}"} # type: ignore + + async def _update_by_id_initial( + self, + application_id: str, + parameters: Optional[_models.ApplicationPatchable] = None, + **kwargs: Any + ) -> _models.ApplicationPatchable: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationPatchable] + + if parameters is not None: + _json = self._serialize.body(parameters, 'ApplicationPatchable') + else: + _json = None + + request = build_update_by_id_request_initial( + application_id=application_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._update_by_id_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('ApplicationPatchable', pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize('ApplicationPatchable', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _update_by_id_initial.metadata = {'url': "/{applicationId}"} # type: ignore + + + @distributed_trace_async + async def begin_update_by_id( + self, + application_id: str, + parameters: Optional[_models.ApplicationPatchable] = None, + **kwargs: Any + ) -> AsyncLROPoller[_models.ApplicationPatchable]: + """Updates an existing managed application. + + :param application_id: The fully qualified ID of the managed application, including the managed + application name and the managed application resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/Microsoft.Solutions/applications/{application-name}. + :type application_id: str + :param parameters: Parameters supplied to update an existing managed application. Default value + is None. + :type parameters: ~azure.mgmt.managedapplication.v2018_02_01.models.ApplicationPatchable + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ApplicationPatchable or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.managedapplication.v2018_02_01.models.ApplicationPatchable] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationPatchable] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._update_by_id_initial( # type: ignore + application_id=application_id, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('ApplicationPatchable', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_update_by_id.metadata = {'url': "/{applicationId}"} # type: ignore + + async def _refresh_permissions_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + application_name: str, + **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_refresh_permissions_request_initial( + resource_group_name=resource_group_name, + application_name=application_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._refresh_permissions_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _refresh_permissions_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}/refreshPermissions"} # type: ignore + + + @distributed_trace_async + async def begin_refresh_permissions( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + application_name: str, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Refresh Permissions for application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_name: The name of the managed application. + :type application_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._refresh_permissions_initial( # type: ignore + resource_group_name=resource_group_name, + application_name=application_name, + api_version=api_version, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'location'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_refresh_permissions.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}/refreshPermissions"} # type: ignore diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_02_01/aio/operations/_patch.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_02_01/aio/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_02_01/aio/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_02_01/models/__init__.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_02_01/models/__init__.py new file mode 100644 index 000000000000..2ce1b3983a9d --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_02_01/models/__init__.py @@ -0,0 +1,99 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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 Application +from ._models_py3 import ApplicationArtifact +from ._models_py3 import ApplicationAuthorization +from ._models_py3 import ApplicationBillingDetailsDefinition +from ._models_py3 import ApplicationClientDetails +from ._models_py3 import ApplicationDefinition +from ._models_py3 import ApplicationDefinitionArtifact +from ._models_py3 import ApplicationDefinitionListResult +from ._models_py3 import ApplicationDefinitionPatchable +from ._models_py3 import ApplicationListResult +from ._models_py3 import ApplicationPackageContact +from ._models_py3 import ApplicationPackageSupportUrls +from ._models_py3 import ApplicationPatchable +from ._models_py3 import ApplicationPolicy +from ._models_py3 import ApplicationPropertiesPatchable +from ._models_py3 import ErrorAdditionalInfo +from ._models_py3 import ErrorDetail +from ._models_py3 import ErrorResponse +from ._models_py3 import GenericResource +from ._models_py3 import Identity +from ._models_py3 import Operation +from ._models_py3 import OperationAutoGenerated +from ._models_py3 import OperationDisplay +from ._models_py3 import OperationDisplayAutoGenerated +from ._models_py3 import OperationListResult +from ._models_py3 import Plan +from ._models_py3 import PlanPatchable +from ._models_py3 import Resource +from ._models_py3 import Sku +from ._models_py3 import UserAssignedResourceIdentity + + +from ._application_client_enums import ( + ActionType, + ApplicationArtifactName, + ApplicationArtifactType, + ApplicationDefinitionArtifactName, + ApplicationLockLevel, + ApplicationManagementMode, + DeploymentMode, + Origin, + ProvisioningState, + ResourceIdentityType, +) +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk +__all__ = [ + 'Application', + 'ApplicationArtifact', + 'ApplicationAuthorization', + 'ApplicationBillingDetailsDefinition', + 'ApplicationClientDetails', + 'ApplicationDefinition', + 'ApplicationDefinitionArtifact', + 'ApplicationDefinitionListResult', + 'ApplicationDefinitionPatchable', + 'ApplicationListResult', + 'ApplicationPackageContact', + 'ApplicationPackageSupportUrls', + 'ApplicationPatchable', + 'ApplicationPolicy', + 'ApplicationPropertiesPatchable', + 'ErrorAdditionalInfo', + 'ErrorDetail', + 'ErrorResponse', + 'GenericResource', + 'Identity', + 'Operation', + 'OperationAutoGenerated', + 'OperationDisplay', + 'OperationDisplayAutoGenerated', + 'OperationListResult', + 'Plan', + 'PlanPatchable', + 'Resource', + 'Sku', + 'UserAssignedResourceIdentity', + 'ActionType', + 'ApplicationArtifactName', + 'ApplicationArtifactType', + 'ApplicationDefinitionArtifactName', + 'ApplicationLockLevel', + 'ApplicationManagementMode', + 'DeploymentMode', + 'Origin', + 'ProvisioningState', + 'ResourceIdentityType', +] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_02_01/models/_application_client_enums.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_02_01/models/_application_client_enums.py new file mode 100644 index 000000000000..9b01d7847642 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_02_01/models/_application_client_enums.py @@ -0,0 +1,102 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# 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 azure.core import CaseInsensitiveEnumMeta + + +class ActionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. + """ + + INTERNAL = "Internal" + +class ApplicationArtifactName(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The managed application artifact name. + """ + + NOT_SPECIFIED = "NotSpecified" + VIEW_DEFINITION = "ViewDefinition" + AUTHORIZATIONS = "Authorizations" + CUSTOM_ROLE_DEFINITION = "CustomRoleDefinition" + +class ApplicationArtifactType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The managed application artifact type. + """ + + NOT_SPECIFIED = "NotSpecified" + TEMPLATE = "Template" + CUSTOM = "Custom" + +class ApplicationDefinitionArtifactName(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The managed application artifact name. + """ + + NOT_SPECIFIED = "NotSpecified" + APPLICATION_RESOURCE_TEMPLATE = "ApplicationResourceTemplate" + CREATE_UI_DEFINITION = "CreateUiDefinition" + MAIN_TEMPLATE_PARAMETERS = "MainTemplateParameters" + +class ApplicationLockLevel(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The managed application lock level. + """ + + CAN_NOT_DELETE = "CanNotDelete" + READ_ONLY = "ReadOnly" + NONE = "None" + +class ApplicationManagementMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The management mode. + """ + + NOT_SPECIFIED = "NotSpecified" + UNMANAGED = "Unmanaged" + MANAGED = "Managed" + +class DeploymentMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The deployment mode. + """ + + NOT_SPECIFIED = "NotSpecified" + INCREMENTAL = "Incremental" + COMPLETE = "Complete" + +class Origin(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit + logs UX. Default value is "user,system" + """ + + USER = "user" + SYSTEM = "system" + USER_SYSTEM = "user,system" + +class ProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Provisioning status of the managed application. + """ + + NOT_SPECIFIED = "NotSpecified" + ACCEPTED = "Accepted" + RUNNING = "Running" + READY = "Ready" + CREATING = "Creating" + CREATED = "Created" + DELETING = "Deleting" + DELETED = "Deleted" + CANCELED = "Canceled" + FAILED = "Failed" + SUCCEEDED = "Succeeded" + UPDATING = "Updating" + +class ResourceIdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The identity type. + """ + + SYSTEM_ASSIGNED = "SystemAssigned" + USER_ASSIGNED = "UserAssigned" + SYSTEM_ASSIGNED_USER_ASSIGNED = "SystemAssigned, UserAssigned" + NONE = "None" diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_02_01/models/_models_py3.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_02_01/models/_models_py3.py new file mode 100644 index 000000000000..dd6996b9aa7a --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_02_01/models/_models_py3.py @@ -0,0 +1,1690 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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, Dict, List, Optional, TYPE_CHECKING, Union + +from azure.core.exceptions import HttpResponseError +import msrest.serialization + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + import __init__ as _models + + +class Resource(msrest.serialization.Model): + """Resource information. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Resource ID. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar location: Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'location': {'key': 'location', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + } + + def __init__( + self, + *, + location: Optional[str] = None, + tags: Optional[Dict[str, str]] = None, + **kwargs + ): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + """ + super(Resource, self).__init__(**kwargs) + self.id = None + self.name = None + self.type = None + self.location = location + self.tags = tags + + +class GenericResource(Resource): + """Resource information. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Resource ID. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar location: Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar managed_by: ID of the resource that manages this resource. + :vartype managed_by: str + :ivar sku: The SKU of the resource. + :vartype sku: ~azure.mgmt.managedapplication.v2018_02_01.models.Sku + """ + + _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'}, + 'location': {'key': 'location', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + 'managed_by': {'key': 'managedBy', 'type': 'str'}, + 'sku': {'key': 'sku', 'type': 'Sku'}, + } + + def __init__( + self, + *, + location: Optional[str] = None, + tags: Optional[Dict[str, str]] = None, + managed_by: Optional[str] = None, + sku: Optional["_models.Sku"] = None, + **kwargs + ): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword managed_by: ID of the resource that manages this resource. + :paramtype managed_by: str + :keyword sku: The SKU of the resource. + :paramtype sku: ~azure.mgmt.managedapplication.v2018_02_01.models.Sku + """ + super(GenericResource, self).__init__(location=location, tags=tags, **kwargs) + self.managed_by = managed_by + self.sku = sku + + +class Application(GenericResource): + """Information about managed application. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar id: Resource ID. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar location: Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar managed_by: ID of the resource that manages this resource. + :vartype managed_by: str + :ivar sku: The SKU of the resource. + :vartype sku: ~azure.mgmt.managedapplication.v2018_02_01.models.Sku + :ivar plan: The plan information. + :vartype plan: ~azure.mgmt.managedapplication.v2018_02_01.models.Plan + :ivar kind: Required. The kind of the managed application. Allowed values are MarketPlace and + ServiceCatalog. + :vartype kind: str + :ivar identity: The identity of the resource. + :vartype identity: ~azure.mgmt.managedapplication.v2018_02_01.models.Identity + :ivar managed_resource_group_id: The managed resource group Id. + :vartype managed_resource_group_id: str + :ivar application_definition_id: The fully qualified path of managed application definition Id. + :vartype application_definition_id: str + :ivar publisher_package_id: The publisher package Id. + :vartype publisher_package_id: str + :ivar parameters: Name and value pairs that define the managed application parameters. It can + be a JObject or a well formed JSON string. + :vartype parameters: any + :ivar outputs: Name and value pairs that define the managed application outputs. + :vartype outputs: any + :ivar provisioning_state: The managed application provisioning state. Known values are: + "NotSpecified", "Accepted", "Running", "Ready", "Creating", "Created", "Deleting", "Deleted", + "Canceled", "Failed", "Succeeded", "Updating". + :vartype provisioning_state: str or + ~azure.mgmt.managedapplication.v2018_02_01.models.ProvisioningState + :ivar billing_details: The managed application billing details. + :vartype billing_details: + ~azure.mgmt.managedapplication.v2018_02_01.models.ApplicationBillingDetailsDefinition + :ivar publisher_tenant_id: The publisher tenant Id. + :vartype publisher_tenant_id: str + :ivar authorizations: The read-only authorizations property that is retrieved from the + application package. + :vartype authorizations: + list[~azure.mgmt.managedapplication.v2018_02_01.models.ApplicationAuthorization] + :ivar customer_support: The read-only customer support property that is retrieved from the + application package. + :vartype customer_support: + ~azure.mgmt.managedapplication.v2018_02_01.models.ApplicationPackageContact + :ivar support_urls: The read-only support URLs property that is retrieved from the application + package. + :vartype support_urls: + ~azure.mgmt.managedapplication.v2018_02_01.models.ApplicationPackageSupportUrls + :ivar artifacts: The collection of managed application artifacts. + :vartype artifacts: list[~azure.mgmt.managedapplication.v2018_02_01.models.ApplicationArtifact] + :ivar created_by: The client entity that created the JIT request. + :vartype created_by: ~azure.mgmt.managedapplication.v2018_02_01.models.ApplicationClientDetails + :ivar updated_by: The client entity that last updated the JIT request. + :vartype updated_by: ~azure.mgmt.managedapplication.v2018_02_01.models.ApplicationClientDetails + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'kind': {'required': True, 'pattern': r'^[-\w\._,\(\)]+$'}, + 'outputs': {'readonly': True}, + 'provisioning_state': {'readonly': True}, + 'billing_details': {'readonly': True}, + 'publisher_tenant_id': {'readonly': True}, + 'authorizations': {'readonly': True}, + 'customer_support': {'readonly': True}, + 'support_urls': {'readonly': True}, + 'artifacts': {'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'}, + 'location': {'key': 'location', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + 'managed_by': {'key': 'managedBy', 'type': 'str'}, + 'sku': {'key': 'sku', 'type': 'Sku'}, + 'plan': {'key': 'plan', 'type': 'Plan'}, + 'kind': {'key': 'kind', 'type': 'str'}, + 'identity': {'key': 'identity', 'type': 'Identity'}, + 'managed_resource_group_id': {'key': 'properties.managedResourceGroupId', 'type': 'str'}, + 'application_definition_id': {'key': 'properties.applicationDefinitionId', 'type': 'str'}, + 'publisher_package_id': {'key': 'properties.publisherPackageId', 'type': 'str'}, + 'parameters': {'key': 'properties.parameters', 'type': 'object'}, + 'outputs': {'key': 'properties.outputs', 'type': 'object'}, + 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + 'billing_details': {'key': 'properties.billingDetails', 'type': 'ApplicationBillingDetailsDefinition'}, + 'publisher_tenant_id': {'key': 'properties.publisherTenantId', 'type': 'str'}, + 'authorizations': {'key': 'properties.authorizations', 'type': '[ApplicationAuthorization]'}, + 'customer_support': {'key': 'properties.customerSupport', 'type': 'ApplicationPackageContact'}, + 'support_urls': {'key': 'properties.supportUrls', 'type': 'ApplicationPackageSupportUrls'}, + 'artifacts': {'key': 'properties.artifacts', 'type': '[ApplicationArtifact]'}, + 'created_by': {'key': 'properties.createdBy', 'type': 'ApplicationClientDetails'}, + 'updated_by': {'key': 'properties.updatedBy', 'type': 'ApplicationClientDetails'}, + } + + def __init__( + self, + *, + kind: str, + location: Optional[str] = None, + tags: Optional[Dict[str, str]] = None, + managed_by: Optional[str] = None, + sku: Optional["_models.Sku"] = None, + plan: Optional["_models.Plan"] = None, + identity: Optional["_models.Identity"] = None, + managed_resource_group_id: Optional[str] = None, + application_definition_id: Optional[str] = None, + publisher_package_id: Optional[str] = None, + parameters: Optional[Any] = None, + **kwargs + ): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword managed_by: ID of the resource that manages this resource. + :paramtype managed_by: str + :keyword sku: The SKU of the resource. + :paramtype sku: ~azure.mgmt.managedapplication.v2018_02_01.models.Sku + :keyword plan: The plan information. + :paramtype plan: ~azure.mgmt.managedapplication.v2018_02_01.models.Plan + :keyword kind: Required. The kind of the managed application. Allowed values are MarketPlace + and ServiceCatalog. + :paramtype kind: str + :keyword identity: The identity of the resource. + :paramtype identity: ~azure.mgmt.managedapplication.v2018_02_01.models.Identity + :keyword managed_resource_group_id: The managed resource group Id. + :paramtype managed_resource_group_id: str + :keyword application_definition_id: The fully qualified path of managed application definition + Id. + :paramtype application_definition_id: str + :keyword publisher_package_id: The publisher package Id. + :paramtype publisher_package_id: str + :keyword parameters: Name and value pairs that define the managed application parameters. It + can be a JObject or a well formed JSON string. + :paramtype parameters: any + """ + super(Application, self).__init__(location=location, tags=tags, managed_by=managed_by, sku=sku, **kwargs) + self.plan = plan + self.kind = kind + self.identity = identity + self.managed_resource_group_id = managed_resource_group_id + self.application_definition_id = application_definition_id + self.publisher_package_id = publisher_package_id + self.parameters = parameters + self.outputs = None + self.provisioning_state = None + self.billing_details = None + self.publisher_tenant_id = None + self.authorizations = None + self.customer_support = None + self.support_urls = None + self.artifacts = None + self.created_by = None + self.updated_by = None + + +class ApplicationArtifact(msrest.serialization.Model): + """Managed application artifact. + + All required parameters must be populated in order to send to Azure. + + :ivar name: Required. The managed application artifact name. Known values are: "NotSpecified", + "ViewDefinition", "Authorizations", "CustomRoleDefinition". + :vartype name: str or ~azure.mgmt.managedapplication.v2018_02_01.models.ApplicationArtifactName + :ivar uri: Required. The managed application artifact blob uri. + :vartype uri: str + :ivar type: Required. The managed application artifact type. Known values are: "NotSpecified", + "Template", "Custom". + :vartype type: str or ~azure.mgmt.managedapplication.v2018_02_01.models.ApplicationArtifactType + """ + + _validation = { + 'name': {'required': True}, + 'uri': {'required': True}, + 'type': {'required': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'uri': {'key': 'uri', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + } + + def __init__( + self, + *, + name: Union[str, "_models.ApplicationArtifactName"], + uri: str, + type: Union[str, "_models.ApplicationArtifactType"], + **kwargs + ): + """ + :keyword name: Required. The managed application artifact name. Known values are: + "NotSpecified", "ViewDefinition", "Authorizations", "CustomRoleDefinition". + :paramtype name: str or + ~azure.mgmt.managedapplication.v2018_02_01.models.ApplicationArtifactName + :keyword uri: Required. The managed application artifact blob uri. + :paramtype uri: str + :keyword type: Required. The managed application artifact type. Known values are: + "NotSpecified", "Template", "Custom". + :paramtype type: str or + ~azure.mgmt.managedapplication.v2018_02_01.models.ApplicationArtifactType + """ + super(ApplicationArtifact, self).__init__(**kwargs) + self.name = name + self.uri = uri + self.type = type + + +class ApplicationAuthorization(msrest.serialization.Model): + """The managed application provider authorization. + + All required parameters must be populated in order to send to Azure. + + :ivar principal_id: Required. The provider's principal identifier. This is the identity that + the provider will use to call ARM to manage the managed application resources. + :vartype principal_id: str + :ivar role_definition_id: Required. The provider's role definition identifier. This role will + define all the permissions that the provider must have on the managed application's container + resource group. This role definition cannot have permission to delete the resource group. + :vartype role_definition_id: str + """ + + _validation = { + 'principal_id': {'required': True}, + 'role_definition_id': {'required': True}, + } + + _attribute_map = { + 'principal_id': {'key': 'principalId', 'type': 'str'}, + 'role_definition_id': {'key': 'roleDefinitionId', 'type': 'str'}, + } + + def __init__( + self, + *, + principal_id: str, + role_definition_id: str, + **kwargs + ): + """ + :keyword principal_id: Required. The provider's principal identifier. This is the identity that + the provider will use to call ARM to manage the managed application resources. + :paramtype principal_id: str + :keyword role_definition_id: Required. The provider's role definition identifier. This role + will define all the permissions that the provider must have on the managed application's + container resource group. This role definition cannot have permission to delete the resource + group. + :paramtype role_definition_id: str + """ + super(ApplicationAuthorization, self).__init__(**kwargs) + self.principal_id = principal_id + self.role_definition_id = role_definition_id + + +class ApplicationBillingDetailsDefinition(msrest.serialization.Model): + """Managed application billing details definition. + + :ivar resource_usage_id: The managed application resource usage Id. + :vartype resource_usage_id: str + """ + + _attribute_map = { + 'resource_usage_id': {'key': 'resourceUsageId', 'type': 'str'}, + } + + def __init__( + self, + *, + resource_usage_id: Optional[str] = None, + **kwargs + ): + """ + :keyword resource_usage_id: The managed application resource usage Id. + :paramtype resource_usage_id: str + """ + super(ApplicationBillingDetailsDefinition, self).__init__(**kwargs) + self.resource_usage_id = resource_usage_id + + +class ApplicationClientDetails(msrest.serialization.Model): + """The application client details to track the entity creating/updating the managed app resource. + + :ivar oid: The client Oid. + :vartype oid: str + :ivar puid: The client Puid. + :vartype puid: str + :ivar application_id: The client application Id. + :vartype application_id: str + """ + + _attribute_map = { + 'oid': {'key': 'oid', 'type': 'str'}, + 'puid': {'key': 'puid', 'type': 'str'}, + 'application_id': {'key': 'applicationId', 'type': 'str'}, + } + + def __init__( + self, + *, + oid: Optional[str] = None, + puid: Optional[str] = None, + application_id: Optional[str] = None, + **kwargs + ): + """ + :keyword oid: The client Oid. + :paramtype oid: str + :keyword puid: The client Puid. + :paramtype puid: str + :keyword application_id: The client application Id. + :paramtype application_id: str + """ + super(ApplicationClientDetails, self).__init__(**kwargs) + self.oid = oid + self.puid = puid + self.application_id = application_id + + +class ApplicationDefinition(GenericResource): + """Information about managed application definition. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar id: Resource ID. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar location: Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar managed_by: ID of the resource that manages this resource. + :vartype managed_by: str + :ivar sku: The SKU of the resource. + :vartype sku: ~azure.mgmt.managedapplication.v2018_02_01.models.Sku + :ivar lock_level: Required. The managed application lock level. Known values are: + "CanNotDelete", "ReadOnly", "None". + :vartype lock_level: str or + ~azure.mgmt.managedapplication.v2018_02_01.models.ApplicationLockLevel + :ivar display_name: The managed application definition display name. + :vartype display_name: str + :ivar is_enabled: A value indicating whether the package is enabled or not. + :vartype is_enabled: bool + :ivar authorizations: The managed application provider authorizations. + :vartype authorizations: + list[~azure.mgmt.managedapplication.v2018_02_01.models.ApplicationAuthorization] + :ivar artifacts: The collection of managed application artifacts. The portal will use the files + specified as artifacts to construct the user experience of creating a managed application from + a managed application definition. + :vartype artifacts: + list[~azure.mgmt.managedapplication.v2018_02_01.models.ApplicationDefinitionArtifact] + :ivar description: The managed application definition description. + :vartype description: str + :ivar package_file_uri: The managed application definition package file Uri. Use this element. + :vartype package_file_uri: str + :ivar main_template: The inline main template json which has resources to be provisioned. It + can be a JObject or well-formed JSON string. + :vartype main_template: any + :ivar create_ui_definition: The createUiDefinition json for the backing template with + Microsoft.Solutions/applications resource. It can be a JObject or well-formed JSON string. + :vartype create_ui_definition: any + :ivar policies: The managed application provider policies. + :vartype policies: list[~azure.mgmt.managedapplication.v2018_02_01.models.ApplicationPolicy] + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'lock_level': {'required': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'location': {'key': 'location', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + 'managed_by': {'key': 'managedBy', 'type': 'str'}, + 'sku': {'key': 'sku', 'type': 'Sku'}, + 'lock_level': {'key': 'properties.lockLevel', 'type': 'str'}, + 'display_name': {'key': 'properties.displayName', 'type': 'str'}, + 'is_enabled': {'key': 'properties.isEnabled', 'type': 'bool'}, + 'authorizations': {'key': 'properties.authorizations', 'type': '[ApplicationAuthorization]'}, + 'artifacts': {'key': 'properties.artifacts', 'type': '[ApplicationDefinitionArtifact]'}, + 'description': {'key': 'properties.description', 'type': 'str'}, + 'package_file_uri': {'key': 'properties.packageFileUri', 'type': 'str'}, + 'main_template': {'key': 'properties.mainTemplate', 'type': 'object'}, + 'create_ui_definition': {'key': 'properties.createUiDefinition', 'type': 'object'}, + 'policies': {'key': 'properties.policies', 'type': '[ApplicationPolicy]'}, + } + + def __init__( + self, + *, + lock_level: Union[str, "_models.ApplicationLockLevel"], + location: Optional[str] = None, + tags: Optional[Dict[str, str]] = None, + managed_by: Optional[str] = None, + sku: Optional["_models.Sku"] = None, + display_name: Optional[str] = None, + is_enabled: Optional[bool] = None, + authorizations: Optional[List["_models.ApplicationAuthorization"]] = None, + artifacts: Optional[List["_models.ApplicationDefinitionArtifact"]] = None, + description: Optional[str] = None, + package_file_uri: Optional[str] = None, + main_template: Optional[Any] = None, + create_ui_definition: Optional[Any] = None, + policies: Optional[List["_models.ApplicationPolicy"]] = None, + **kwargs + ): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword managed_by: ID of the resource that manages this resource. + :paramtype managed_by: str + :keyword sku: The SKU of the resource. + :paramtype sku: ~azure.mgmt.managedapplication.v2018_02_01.models.Sku + :keyword lock_level: Required. The managed application lock level. Known values are: + "CanNotDelete", "ReadOnly", "None". + :paramtype lock_level: str or + ~azure.mgmt.managedapplication.v2018_02_01.models.ApplicationLockLevel + :keyword display_name: The managed application definition display name. + :paramtype display_name: str + :keyword is_enabled: A value indicating whether the package is enabled or not. + :paramtype is_enabled: bool + :keyword authorizations: The managed application provider authorizations. + :paramtype authorizations: + list[~azure.mgmt.managedapplication.v2018_02_01.models.ApplicationAuthorization] + :keyword artifacts: The collection of managed application artifacts. The portal will use the + files specified as artifacts to construct the user experience of creating a managed application + from a managed application definition. + :paramtype artifacts: + list[~azure.mgmt.managedapplication.v2018_02_01.models.ApplicationDefinitionArtifact] + :keyword description: The managed application definition description. + :paramtype description: str + :keyword package_file_uri: The managed application definition package file Uri. Use this + element. + :paramtype package_file_uri: str + :keyword main_template: The inline main template json which has resources to be provisioned. It + can be a JObject or well-formed JSON string. + :paramtype main_template: any + :keyword create_ui_definition: The createUiDefinition json for the backing template with + Microsoft.Solutions/applications resource. It can be a JObject or well-formed JSON string. + :paramtype create_ui_definition: any + :keyword policies: The managed application provider policies. + :paramtype policies: list[~azure.mgmt.managedapplication.v2018_02_01.models.ApplicationPolicy] + """ + super(ApplicationDefinition, self).__init__(location=location, tags=tags, managed_by=managed_by, sku=sku, **kwargs) + self.lock_level = lock_level + self.display_name = display_name + self.is_enabled = is_enabled + self.authorizations = authorizations + self.artifacts = artifacts + self.description = description + self.package_file_uri = package_file_uri + self.main_template = main_template + self.create_ui_definition = create_ui_definition + self.policies = policies + + +class ApplicationDefinitionArtifact(msrest.serialization.Model): + """Application definition artifact. + + All required parameters must be populated in order to send to Azure. + + :ivar name: Required. The managed application definition artifact name. Known values are: + "NotSpecified", "ApplicationResourceTemplate", "CreateUiDefinition", "MainTemplateParameters". + :vartype name: str or + ~azure.mgmt.managedapplication.v2018_02_01.models.ApplicationDefinitionArtifactName + :ivar uri: Required. The managed application definition artifact blob uri. + :vartype uri: str + :ivar type: Required. The managed application definition artifact type. Known values are: + "NotSpecified", "Template", "Custom". + :vartype type: str or ~azure.mgmt.managedapplication.v2018_02_01.models.ApplicationArtifactType + """ + + _validation = { + 'name': {'required': True}, + 'uri': {'required': True}, + 'type': {'required': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'uri': {'key': 'uri', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + } + + def __init__( + self, + *, + name: Union[str, "_models.ApplicationDefinitionArtifactName"], + uri: str, + type: Union[str, "_models.ApplicationArtifactType"], + **kwargs + ): + """ + :keyword name: Required. The managed application definition artifact name. Known values are: + "NotSpecified", "ApplicationResourceTemplate", "CreateUiDefinition", "MainTemplateParameters". + :paramtype name: str or + ~azure.mgmt.managedapplication.v2018_02_01.models.ApplicationDefinitionArtifactName + :keyword uri: Required. The managed application definition artifact blob uri. + :paramtype uri: str + :keyword type: Required. The managed application definition artifact type. Known values are: + "NotSpecified", "Template", "Custom". + :paramtype type: str or + ~azure.mgmt.managedapplication.v2018_02_01.models.ApplicationArtifactType + """ + super(ApplicationDefinitionArtifact, self).__init__(**kwargs) + self.name = name + self.uri = uri + self.type = type + + +class ApplicationDefinitionListResult(msrest.serialization.Model): + """List of managed application definitions. + + :ivar value: The array of managed application definitions. + :vartype value: list[~azure.mgmt.managedapplication.v2018_02_01.models.ApplicationDefinition] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[ApplicationDefinition]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["_models.ApplicationDefinition"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + """ + :keyword value: The array of managed application definitions. + :paramtype value: list[~azure.mgmt.managedapplication.v2018_02_01.models.ApplicationDefinition] + :keyword next_link: The URL to use for getting the next set of results. + :paramtype next_link: str + """ + super(ApplicationDefinitionListResult, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class ApplicationDefinitionPatchable(msrest.serialization.Model): + """Information about an application definition request. + + :ivar tags: A set of tags. Application definition tags. + :vartype tags: dict[str, str] + """ + + _attribute_map = { + 'tags': {'key': 'tags', 'type': '{str}'}, + } + + def __init__( + self, + *, + tags: Optional[Dict[str, str]] = None, + **kwargs + ): + """ + :keyword tags: A set of tags. Application definition tags. + :paramtype tags: dict[str, str] + """ + super(ApplicationDefinitionPatchable, self).__init__(**kwargs) + self.tags = tags + + +class ApplicationListResult(msrest.serialization.Model): + """List of managed applications. + + :ivar value: The array of managed applications. + :vartype value: list[~azure.mgmt.managedapplication.v2018_02_01.models.Application] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Application]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["_models.Application"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + """ + :keyword value: The array of managed applications. + :paramtype value: list[~azure.mgmt.managedapplication.v2018_02_01.models.Application] + :keyword next_link: The URL to use for getting the next set of results. + :paramtype next_link: str + """ + super(ApplicationListResult, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class ApplicationPackageContact(msrest.serialization.Model): + """The application package contact information. + + All required parameters must be populated in order to send to Azure. + + :ivar contact_name: The contact name. + :vartype contact_name: str + :ivar email: Required. The contact email. + :vartype email: str + :ivar phone: Required. The contact phone number. + :vartype phone: str + """ + + _validation = { + 'email': {'required': True}, + 'phone': {'required': True}, + } + + _attribute_map = { + 'contact_name': {'key': 'contactName', 'type': 'str'}, + 'email': {'key': 'email', 'type': 'str'}, + 'phone': {'key': 'phone', 'type': 'str'}, + } + + def __init__( + self, + *, + email: str, + phone: str, + contact_name: Optional[str] = None, + **kwargs + ): + """ + :keyword contact_name: The contact name. + :paramtype contact_name: str + :keyword email: Required. The contact email. + :paramtype email: str + :keyword phone: Required. The contact phone number. + :paramtype phone: str + """ + super(ApplicationPackageContact, self).__init__(**kwargs) + self.contact_name = contact_name + self.email = email + self.phone = phone + + +class ApplicationPackageSupportUrls(msrest.serialization.Model): + """The appliance package support URLs. + + :ivar public_azure: The public azure support URL. + :vartype public_azure: str + :ivar government_cloud: The government cloud support URL. + :vartype government_cloud: str + """ + + _attribute_map = { + 'public_azure': {'key': 'publicAzure', 'type': 'str'}, + 'government_cloud': {'key': 'governmentCloud', 'type': 'str'}, + } + + def __init__( + self, + *, + public_azure: Optional[str] = None, + government_cloud: Optional[str] = None, + **kwargs + ): + """ + :keyword public_azure: The public azure support URL. + :paramtype public_azure: str + :keyword government_cloud: The government cloud support URL. + :paramtype government_cloud: str + """ + super(ApplicationPackageSupportUrls, self).__init__(**kwargs) + self.public_azure = public_azure + self.government_cloud = government_cloud + + +class ApplicationPatchable(GenericResource): + """Information about managed application. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Resource ID. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar location: Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar managed_by: ID of the resource that manages this resource. + :vartype managed_by: str + :ivar sku: The SKU of the resource. + :vartype sku: ~azure.mgmt.managedapplication.v2018_02_01.models.Sku + :ivar plan: The plan information. + :vartype plan: ~azure.mgmt.managedapplication.v2018_02_01.models.PlanPatchable + :ivar kind: The kind of the managed application. Allowed values are MarketPlace and + ServiceCatalog. + :vartype kind: str + :ivar identity: The identity of the resource. + :vartype identity: ~azure.mgmt.managedapplication.v2018_02_01.models.Identity + :ivar managed_resource_group_id: The managed resource group Id. + :vartype managed_resource_group_id: str + :ivar application_definition_id: The fully qualified path of managed application definition Id. + :vartype application_definition_id: str + :ivar publisher_package_id: The publisher package Id. + :vartype publisher_package_id: str + :ivar parameters: Name and value pairs that define the managed application parameters. It can + be a JObject or a well formed JSON string. + :vartype parameters: any + :ivar outputs: Name and value pairs that define the managed application outputs. + :vartype outputs: any + :ivar provisioning_state: The managed application provisioning state. Known values are: + "NotSpecified", "Accepted", "Running", "Ready", "Creating", "Created", "Deleting", "Deleted", + "Canceled", "Failed", "Succeeded", "Updating". + :vartype provisioning_state: str or + ~azure.mgmt.managedapplication.v2018_02_01.models.ProvisioningState + :ivar billing_details: The managed application billing details. + :vartype billing_details: + ~azure.mgmt.managedapplication.v2018_02_01.models.ApplicationBillingDetailsDefinition + :ivar publisher_tenant_id: The publisher tenant Id. + :vartype publisher_tenant_id: str + :ivar authorizations: The read-only authorizations property that is retrieved from the + application package. + :vartype authorizations: + list[~azure.mgmt.managedapplication.v2018_02_01.models.ApplicationAuthorization] + :ivar customer_support: The read-only customer support property that is retrieved from the + application package. + :vartype customer_support: + ~azure.mgmt.managedapplication.v2018_02_01.models.ApplicationPackageContact + :ivar support_urls: The read-only support URLs property that is retrieved from the application + package. + :vartype support_urls: + ~azure.mgmt.managedapplication.v2018_02_01.models.ApplicationPackageSupportUrls + :ivar artifacts: The collection of managed application artifacts. + :vartype artifacts: list[~azure.mgmt.managedapplication.v2018_02_01.models.ApplicationArtifact] + :ivar created_by: The client entity that created the JIT request. + :vartype created_by: ~azure.mgmt.managedapplication.v2018_02_01.models.ApplicationClientDetails + :ivar updated_by: The client entity that last updated the JIT request. + :vartype updated_by: ~azure.mgmt.managedapplication.v2018_02_01.models.ApplicationClientDetails + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'kind': {'pattern': r'^[-\w\._,\(\)]+$'}, + 'outputs': {'readonly': True}, + 'provisioning_state': {'readonly': True}, + 'billing_details': {'readonly': True}, + 'publisher_tenant_id': {'readonly': True}, + 'authorizations': {'readonly': True}, + 'customer_support': {'readonly': True}, + 'support_urls': {'readonly': True}, + 'artifacts': {'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'}, + 'location': {'key': 'location', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + 'managed_by': {'key': 'managedBy', 'type': 'str'}, + 'sku': {'key': 'sku', 'type': 'Sku'}, + 'plan': {'key': 'plan', 'type': 'PlanPatchable'}, + 'kind': {'key': 'kind', 'type': 'str'}, + 'identity': {'key': 'identity', 'type': 'Identity'}, + 'managed_resource_group_id': {'key': 'properties.managedResourceGroupId', 'type': 'str'}, + 'application_definition_id': {'key': 'properties.applicationDefinitionId', 'type': 'str'}, + 'publisher_package_id': {'key': 'properties.publisherPackageId', 'type': 'str'}, + 'parameters': {'key': 'properties.parameters', 'type': 'object'}, + 'outputs': {'key': 'properties.outputs', 'type': 'object'}, + 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + 'billing_details': {'key': 'properties.billingDetails', 'type': 'ApplicationBillingDetailsDefinition'}, + 'publisher_tenant_id': {'key': 'properties.publisherTenantId', 'type': 'str'}, + 'authorizations': {'key': 'properties.authorizations', 'type': '[ApplicationAuthorization]'}, + 'customer_support': {'key': 'properties.customerSupport', 'type': 'ApplicationPackageContact'}, + 'support_urls': {'key': 'properties.supportUrls', 'type': 'ApplicationPackageSupportUrls'}, + 'artifacts': {'key': 'properties.artifacts', 'type': '[ApplicationArtifact]'}, + 'created_by': {'key': 'properties.createdBy', 'type': 'ApplicationClientDetails'}, + 'updated_by': {'key': 'properties.updatedBy', 'type': 'ApplicationClientDetails'}, + } + + def __init__( + self, + *, + location: Optional[str] = None, + tags: Optional[Dict[str, str]] = None, + managed_by: Optional[str] = None, + sku: Optional["_models.Sku"] = None, + plan: Optional["_models.PlanPatchable"] = None, + kind: Optional[str] = None, + identity: Optional["_models.Identity"] = None, + managed_resource_group_id: Optional[str] = None, + application_definition_id: Optional[str] = None, + publisher_package_id: Optional[str] = None, + parameters: Optional[Any] = None, + **kwargs + ): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword managed_by: ID of the resource that manages this resource. + :paramtype managed_by: str + :keyword sku: The SKU of the resource. + :paramtype sku: ~azure.mgmt.managedapplication.v2018_02_01.models.Sku + :keyword plan: The plan information. + :paramtype plan: ~azure.mgmt.managedapplication.v2018_02_01.models.PlanPatchable + :keyword kind: The kind of the managed application. Allowed values are MarketPlace and + ServiceCatalog. + :paramtype kind: str + :keyword identity: The identity of the resource. + :paramtype identity: ~azure.mgmt.managedapplication.v2018_02_01.models.Identity + :keyword managed_resource_group_id: The managed resource group Id. + :paramtype managed_resource_group_id: str + :keyword application_definition_id: The fully qualified path of managed application definition + Id. + :paramtype application_definition_id: str + :keyword publisher_package_id: The publisher package Id. + :paramtype publisher_package_id: str + :keyword parameters: Name and value pairs that define the managed application parameters. It + can be a JObject or a well formed JSON string. + :paramtype parameters: any + """ + super(ApplicationPatchable, self).__init__(location=location, tags=tags, managed_by=managed_by, sku=sku, **kwargs) + self.plan = plan + self.kind = kind + self.identity = identity + self.managed_resource_group_id = managed_resource_group_id + self.application_definition_id = application_definition_id + self.publisher_package_id = publisher_package_id + self.parameters = parameters + self.outputs = None + self.provisioning_state = None + self.billing_details = None + self.publisher_tenant_id = None + self.authorizations = None + self.customer_support = None + self.support_urls = None + self.artifacts = None + self.created_by = None + self.updated_by = None + + +class ApplicationPolicy(msrest.serialization.Model): + """Managed application policy. + + :ivar name: The policy name. + :vartype name: str + :ivar policy_definition_id: The policy definition Id. + :vartype policy_definition_id: str + :ivar parameters: The policy parameters. + :vartype parameters: str + """ + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'policy_definition_id': {'key': 'policyDefinitionId', 'type': 'str'}, + 'parameters': {'key': 'parameters', 'type': 'str'}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + policy_definition_id: Optional[str] = None, + parameters: Optional[str] = None, + **kwargs + ): + """ + :keyword name: The policy name. + :paramtype name: str + :keyword policy_definition_id: The policy definition Id. + :paramtype policy_definition_id: str + :keyword parameters: The policy parameters. + :paramtype parameters: str + """ + super(ApplicationPolicy, self).__init__(**kwargs) + self.name = name + self.policy_definition_id = policy_definition_id + self.parameters = parameters + + +class ApplicationPropertiesPatchable(msrest.serialization.Model): + """The managed application properties. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar managed_resource_group_id: The managed resource group Id. + :vartype managed_resource_group_id: str + :ivar application_definition_id: The fully qualified path of managed application definition Id. + :vartype application_definition_id: str + :ivar parameters: Name and value pairs that define the managed application parameters. It can + be a JObject or a well formed JSON string. + :vartype parameters: any + :ivar outputs: Name and value pairs that define the managed application outputs. + :vartype outputs: any + :ivar provisioning_state: The managed application provisioning state. Known values are: + "NotSpecified", "Accepted", "Running", "Ready", "Creating", "Created", "Deleting", "Deleted", + "Canceled", "Failed", "Succeeded", "Updating". + :vartype provisioning_state: str or + ~azure.mgmt.managedapplication.v2018_02_01.models.ProvisioningState + """ + + _validation = { + 'outputs': {'readonly': True}, + 'provisioning_state': {'readonly': True}, + } + + _attribute_map = { + 'managed_resource_group_id': {'key': 'managedResourceGroupId', 'type': 'str'}, + 'application_definition_id': {'key': 'applicationDefinitionId', 'type': 'str'}, + 'parameters': {'key': 'parameters', 'type': 'object'}, + 'outputs': {'key': 'outputs', 'type': 'object'}, + 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, + } + + def __init__( + self, + *, + managed_resource_group_id: Optional[str] = None, + application_definition_id: Optional[str] = None, + parameters: Optional[Any] = None, + **kwargs + ): + """ + :keyword managed_resource_group_id: The managed resource group Id. + :paramtype managed_resource_group_id: str + :keyword application_definition_id: The fully qualified path of managed application definition + Id. + :paramtype application_definition_id: str + :keyword parameters: Name and value pairs that define the managed application parameters. It + can be a JObject or a well formed JSON string. + :paramtype parameters: any + """ + super(ApplicationPropertiesPatchable, self).__init__(**kwargs) + self.managed_resource_group_id = managed_resource_group_id + self.application_definition_id = application_definition_id + self.parameters = parameters + self.outputs = None + self.provisioning_state = None + + +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.managedapplication.v2018_02_01.models.ErrorDetail] + :ivar additional_info: The error additional info. + :vartype additional_info: + list[~azure.mgmt.managedapplication.v2018_02_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.). + + :ivar error: The error object. + :vartype error: ~azure.mgmt.managedapplication.v2018_02_01.models.ErrorDetail + """ + + _attribute_map = { + 'error': {'key': 'error', 'type': 'ErrorDetail'}, + } + + def __init__( + self, + *, + error: Optional["_models.ErrorDetail"] = None, + **kwargs + ): + """ + :keyword error: The error object. + :paramtype error: ~azure.mgmt.managedapplication.v2018_02_01.models.ErrorDetail + """ + super(ErrorResponse, self).__init__(**kwargs) + self.error = error + + +class Identity(msrest.serialization.Model): + """Identity for the resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar principal_id: The principal ID of resource identity. + :vartype principal_id: str + :ivar tenant_id: The tenant ID of resource. + :vartype tenant_id: str + :ivar type: The identity type. Known values are: "SystemAssigned", "UserAssigned", + "SystemAssigned, UserAssigned", "None". + :vartype type: str or ~azure.mgmt.managedapplication.v2018_02_01.models.ResourceIdentityType + :ivar user_assigned_identities: The list of user identities associated with the resource. The + user identity dictionary key references will be resource ids in the form: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'. + :vartype user_assigned_identities: dict[str, + ~azure.mgmt.managedapplication.v2018_02_01.models.UserAssignedResourceIdentity] + """ + + _validation = { + 'principal_id': {'readonly': True}, + 'tenant_id': {'readonly': True}, + } + + _attribute_map = { + 'principal_id': {'key': 'principalId', 'type': 'str'}, + 'tenant_id': {'key': 'tenantId', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'user_assigned_identities': {'key': 'userAssignedIdentities', 'type': '{UserAssignedResourceIdentity}'}, + } + + def __init__( + self, + *, + type: Optional[Union[str, "_models.ResourceIdentityType"]] = None, + user_assigned_identities: Optional[Dict[str, "_models.UserAssignedResourceIdentity"]] = None, + **kwargs + ): + """ + :keyword type: The identity type. Known values are: "SystemAssigned", "UserAssigned", + "SystemAssigned, UserAssigned", "None". + :paramtype type: str or ~azure.mgmt.managedapplication.v2018_02_01.models.ResourceIdentityType + :keyword user_assigned_identities: The list of user identities associated with the resource. + The user identity dictionary key references will be resource ids in the form: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'. + :paramtype user_assigned_identities: dict[str, + ~azure.mgmt.managedapplication.v2018_02_01.models.UserAssignedResourceIdentity] + """ + super(Identity, self).__init__(**kwargs) + self.principal_id = None + self.tenant_id = None + self.type = type + self.user_assigned_identities = user_assigned_identities + + +class Operation(msrest.serialization.Model): + """Details of a REST API operation, returned from the Resource Provider Operations API. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name: The name of the operation, as per Resource-Based Access Control (RBAC). Examples: + "Microsoft.Compute/virtualMachines/write", "Microsoft.Compute/virtualMachines/capture/action". + :vartype name: str + :ivar is_data_action: Whether the operation applies to data-plane. This is "true" for + data-plane operations and "false" for ARM/control-plane operations. + :vartype is_data_action: bool + :ivar display: Localized display information for this particular operation. + :vartype display: ~azure.mgmt.managedapplication.v2018_02_01.models.OperationDisplay + :ivar origin: The intended executor of the operation; as in Resource Based Access Control + (RBAC) and audit logs UX. Default value is "user,system". Known values are: "user", "system", + "user,system". + :vartype origin: str or ~azure.mgmt.managedapplication.v2018_02_01.models.Origin + :ivar action_type: Enum. Indicates the action type. "Internal" refers to actions that are for + internal only APIs. Known values are: "Internal". + :vartype action_type: str or ~azure.mgmt.managedapplication.v2018_02_01.models.ActionType + """ + + _validation = { + 'name': {'readonly': True}, + 'is_data_action': {'readonly': True}, + 'origin': {'readonly': True}, + 'action_type': {'readonly': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'is_data_action': {'key': 'isDataAction', 'type': 'bool'}, + 'display': {'key': 'display', 'type': 'OperationDisplay'}, + 'origin': {'key': 'origin', 'type': 'str'}, + 'action_type': {'key': 'actionType', 'type': 'str'}, + } + + def __init__( + self, + *, + display: Optional["_models.OperationDisplay"] = None, + **kwargs + ): + """ + :keyword display: Localized display information for this particular operation. + :paramtype display: ~azure.mgmt.managedapplication.v2018_02_01.models.OperationDisplay + """ + super(Operation, self).__init__(**kwargs) + self.name = None + self.is_data_action = None + self.display = display + self.origin = None + self.action_type = None + + +class OperationAutoGenerated(msrest.serialization.Model): + """Microsoft.Solutions operation. + + :ivar name: Operation name: {provider}/{resource}/{operation}. + :vartype name: str + :ivar display: The object that represents the operation. + :vartype display: + ~azure.mgmt.managedapplication.v2018_02_01.models.OperationDisplayAutoGenerated + """ + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'display': {'key': 'display', 'type': 'OperationDisplayAutoGenerated'}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + display: Optional["_models.OperationDisplayAutoGenerated"] = None, + **kwargs + ): + """ + :keyword name: Operation name: {provider}/{resource}/{operation}. + :paramtype name: str + :keyword display: The object that represents the operation. + :paramtype display: + ~azure.mgmt.managedapplication.v2018_02_01.models.OperationDisplayAutoGenerated + """ + super(OperationAutoGenerated, self).__init__(**kwargs) + self.name = name + self.display = display + + +class OperationDisplay(msrest.serialization.Model): + """Localized display information for this particular operation. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar provider: The localized friendly form of the resource provider name, e.g. "Microsoft + Monitoring Insights" or "Microsoft Compute". + :vartype provider: str + :ivar resource: The localized friendly name of the resource type related to this operation. + E.g. "Virtual Machines" or "Job Schedule Collections". + :vartype resource: str + :ivar operation: The concise, localized friendly name for the operation; suitable for + dropdowns. E.g. "Create or Update Virtual Machine", "Restart Virtual Machine". + :vartype operation: str + :ivar description: The short, localized friendly description of the operation; suitable for + tool tips and detailed views. + :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 OperationDisplayAutoGenerated(msrest.serialization.Model): + """The object that represents the operation. + + :ivar provider: Service provider: Microsoft.Solutions. + :vartype provider: str + :ivar resource: Resource on which the operation is performed: Application, JitRequest, etc. + :vartype resource: str + :ivar operation: Operation type: Read, write, delete, etc. + :vartype operation: str + """ + + _attribute_map = { + 'provider': {'key': 'provider', 'type': 'str'}, + 'resource': {'key': 'resource', 'type': 'str'}, + 'operation': {'key': 'operation', 'type': 'str'}, + } + + def __init__( + self, + *, + provider: Optional[str] = None, + resource: Optional[str] = None, + operation: Optional[str] = None, + **kwargs + ): + """ + :keyword provider: Service provider: Microsoft.Solutions. + :paramtype provider: str + :keyword resource: Resource on which the operation is performed: Application, JitRequest, etc. + :paramtype resource: str + :keyword operation: Operation type: Read, write, delete, etc. + :paramtype operation: str + """ + super(OperationDisplayAutoGenerated, self).__init__(**kwargs) + self.provider = provider + self.resource = resource + self.operation = operation + + +class OperationListResult(msrest.serialization.Model): + """A list of REST API operations supported by an Azure Resource Provider. It contains an URL link to get the next set of results. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: List of operations supported by the resource provider. + :vartype value: list[~azure.mgmt.managedapplication.v2018_02_01.models.Operation] + :ivar next_link: URL to get the next set of operation list results (if there are any). + :vartype next_link: str + """ + + _validation = { + 'value': {'readonly': True}, + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Operation]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(OperationListResult, self).__init__(**kwargs) + self.value = None + self.next_link = None + + +class Plan(msrest.serialization.Model): + """Plan for the managed application. + + All required parameters must be populated in order to send to Azure. + + :ivar name: Required. The plan name. + :vartype name: str + :ivar publisher: Required. The publisher ID. + :vartype publisher: str + :ivar product: Required. The product code. + :vartype product: str + :ivar promotion_code: The promotion code. + :vartype promotion_code: str + :ivar version: Required. The plan's version. + :vartype version: str + """ + + _validation = { + 'name': {'required': True}, + 'publisher': {'required': True}, + 'product': {'required': True}, + 'version': {'required': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'publisher': {'key': 'publisher', 'type': 'str'}, + 'product': {'key': 'product', 'type': 'str'}, + 'promotion_code': {'key': 'promotionCode', 'type': 'str'}, + 'version': {'key': 'version', 'type': 'str'}, + } + + def __init__( + self, + *, + name: str, + publisher: str, + product: str, + version: str, + promotion_code: Optional[str] = None, + **kwargs + ): + """ + :keyword name: Required. The plan name. + :paramtype name: str + :keyword publisher: Required. The publisher ID. + :paramtype publisher: str + :keyword product: Required. The product code. + :paramtype product: str + :keyword promotion_code: The promotion code. + :paramtype promotion_code: str + :keyword version: Required. The plan's version. + :paramtype version: str + """ + super(Plan, self).__init__(**kwargs) + self.name = name + self.publisher = publisher + self.product = product + self.promotion_code = promotion_code + self.version = version + + +class PlanPatchable(msrest.serialization.Model): + """Plan for the managed application. + + :ivar name: The plan name. + :vartype name: str + :ivar publisher: The publisher ID. + :vartype publisher: str + :ivar product: The product code. + :vartype product: str + :ivar promotion_code: The promotion code. + :vartype promotion_code: str + :ivar version: The plan's version. + :vartype version: str + """ + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'publisher': {'key': 'publisher', 'type': 'str'}, + 'product': {'key': 'product', 'type': 'str'}, + 'promotion_code': {'key': 'promotionCode', 'type': 'str'}, + 'version': {'key': 'version', 'type': 'str'}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + publisher: Optional[str] = None, + product: Optional[str] = None, + promotion_code: Optional[str] = None, + version: Optional[str] = None, + **kwargs + ): + """ + :keyword name: The plan name. + :paramtype name: str + :keyword publisher: The publisher ID. + :paramtype publisher: str + :keyword product: The product code. + :paramtype product: str + :keyword promotion_code: The promotion code. + :paramtype promotion_code: str + :keyword version: The plan's version. + :paramtype version: str + """ + super(PlanPatchable, self).__init__(**kwargs) + self.name = name + self.publisher = publisher + self.product = product + self.promotion_code = promotion_code + self.version = version + + +class Sku(msrest.serialization.Model): + """SKU for the resource. + + All required parameters must be populated in order to send to Azure. + + :ivar name: Required. The SKU name. + :vartype name: str + :ivar tier: The SKU tier. + :vartype tier: str + :ivar size: The SKU size. + :vartype size: str + :ivar family: The SKU family. + :vartype family: str + :ivar model: The SKU model. + :vartype model: str + :ivar capacity: The SKU capacity. + :vartype capacity: int + """ + + _validation = { + 'name': {'required': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'tier': {'key': 'tier', 'type': 'str'}, + 'size': {'key': 'size', 'type': 'str'}, + 'family': {'key': 'family', 'type': 'str'}, + 'model': {'key': 'model', 'type': 'str'}, + 'capacity': {'key': 'capacity', 'type': 'int'}, + } + + def __init__( + self, + *, + name: str, + tier: Optional[str] = None, + size: Optional[str] = None, + family: Optional[str] = None, + model: Optional[str] = None, + capacity: Optional[int] = None, + **kwargs + ): + """ + :keyword name: Required. The SKU name. + :paramtype name: str + :keyword tier: The SKU tier. + :paramtype tier: str + :keyword size: The SKU size. + :paramtype size: str + :keyword family: The SKU family. + :paramtype family: str + :keyword model: The SKU model. + :paramtype model: str + :keyword capacity: The SKU capacity. + :paramtype capacity: int + """ + super(Sku, self).__init__(**kwargs) + self.name = name + self.tier = tier + self.size = size + self.family = family + self.model = model + self.capacity = capacity + + +class UserAssignedResourceIdentity(msrest.serialization.Model): + """Represents the user assigned identity that is contained within the UserAssignedIdentities dictionary on ResourceIdentity. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar principal_id: The principal id of user assigned identity. + :vartype principal_id: str + :ivar tenant_id: The tenant id of user assigned identity. + :vartype tenant_id: str + """ + + _validation = { + 'principal_id': {'readonly': True}, + 'tenant_id': {'readonly': True}, + } + + _attribute_map = { + 'principal_id': {'key': 'principalId', 'type': 'str'}, + 'tenant_id': {'key': 'tenantId', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(UserAssignedResourceIdentity, self).__init__(**kwargs) + self.principal_id = None + self.tenant_id = None diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_02_01/models/_patch.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_02_01/models/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_02_01/models/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_02_01/operations/__init__.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_02_01/operations/__init__.py new file mode 100644 index 000000000000..47d8f29e4b2c --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_02_01/operations/__init__.py @@ -0,0 +1,22 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._application_client_operations import ApplicationClientOperationsMixin +from ._applications_operations import ApplicationsOperations +from ._application_definitions_operations import ApplicationDefinitionsOperations + +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk +__all__ = [ + 'ApplicationClientOperationsMixin', + 'ApplicationsOperations', + 'ApplicationDefinitionsOperations', +] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_02_01/operations/_application_client_operations.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_02_01/operations/_application_client_operations.py new file mode 100644 index 000000000000..d9066d5b2b40 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_02_01/operations/_application_client_operations.py @@ -0,0 +1,134 @@ +# 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.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._vendor import MixinABC, _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_operations_request( + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.Solutions/operations") + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + +class ApplicationClientOperationsMixin(MixinABC): + + @distributed_trace + def list_operations( + self, + **kwargs: Any + ) -> Iterable[_models.OperationListResult]: + """Lists all of the available Microsoft.Solutions REST API operations. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either OperationListResult or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.managedapplication.v2018_02_01.models.OperationListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # 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', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_operations_request( + api_version=api_version, + template_url=self.list_operations.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_operations_request( + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list_operations.metadata = {'url': "/providers/Microsoft.Solutions/operations"} # type: ignore diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_02_01/operations/_application_definitions_operations.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_02_01/operations/_application_definitions_operations.py new file mode 100644 index 000000000000..afda76778fe5 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_02_01/operations/_application_definitions_operations.py @@ -0,0 +1,1158 @@ +# 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.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._vendor import MixinABC, _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_request( + resource_group_name: str, + application_definition_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "applicationDefinitionName": _SERIALIZER.url("application_definition_name", application_definition_name, 'str', max_length=64, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_delete_request( + resource_group_name: str, + application_definition_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "applicationDefinitionName": _SERIALIZER.url("application_definition_name", application_definition_name, 'str', max_length=64, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_create_or_update_request( + resource_group_name: str, + application_definition_name: str, + subscription_id: str, + *, + json: Optional[_models.ApplicationDefinition] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "applicationDefinitionName": _SERIALIZER.url("application_definition_name", application_definition_name, 'str', max_length=64, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_update_request( + subscription_id: str, + resource_group_name: str, + application_definition_name: str, + *, + json: Optional[_models.ApplicationDefinitionPatchable] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "applicationDefinitionName": _SERIALIZER.url("application_definition_name", application_definition_name, 'str', max_length=64, min_length=3), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_list_by_resource_group_request( + resource_group_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_list_by_subscription_request( + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Solutions/applicationDefinitions") + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_get_by_id_request( + resource_group_name: str, + application_definition_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "applicationDefinitionName": _SERIALIZER.url("application_definition_name", application_definition_name, 'str', max_length=64, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_delete_by_id_request( + resource_group_name: str, + application_definition_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "applicationDefinitionName": _SERIALIZER.url("application_definition_name", application_definition_name, 'str', max_length=64, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_create_or_update_by_id_request( + resource_group_name: str, + application_definition_name: str, + subscription_id: str, + *, + json: Optional[_models.ApplicationDefinition] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "applicationDefinitionName": _SERIALIZER.url("application_definition_name", application_definition_name, 'str', max_length=64, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_update_by_id_request( + subscription_id: str, + resource_group_name: str, + application_definition_name: str, + *, + json: Optional[_models.ApplicationDefinitionPatchable] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "applicationDefinitionName": _SERIALIZER.url("application_definition_name", application_definition_name, 'str', max_length=64, min_length=3), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + +class ApplicationDefinitionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.managedapplication.v2018_02_01.ApplicationClient`'s + :attr:`application_definitions` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + + @distributed_trace + def get( + self, + resource_group_name: str, + application_definition_name: str, + **kwargs: Any + ) -> Optional[_models.ApplicationDefinition]: + """Gets the managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. + :type application_definition_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ApplicationDefinition, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2018_02_01.models.ApplicationDefinition or None + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.ApplicationDefinition]] + + + request = build_get_request( + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('ApplicationDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore + + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + application_definition_name: str, + **kwargs: Any + ) -> None: + """Deletes the managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition to delete. + :type application_definition_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_request( + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore + + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + application_definition_name: str, + parameters: _models.ApplicationDefinition, + **kwargs: Any + ) -> _models.ApplicationDefinition: + """Creates or updates a managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. + :type application_definition_name: str + :param parameters: Parameters supplied to the create or update an managed application + definition. + :type parameters: ~azure.mgmt.managedapplication.v2018_02_01.models.ApplicationDefinition + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ApplicationDefinition, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2018_02_01.models.ApplicationDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationDefinition] + + _json = self._serialize.body(parameters, 'ApplicationDefinition') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # 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, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('ApplicationDefinition', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('ApplicationDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore + + + @distributed_trace + def update( + self, + resource_group_name: str, + application_definition_name: str, + parameters: _models.ApplicationDefinitionPatchable, + **kwargs: Any + ) -> _models.ApplicationDefinition: + """Updates the managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. + :type application_definition_name: str + :param parameters: Parameters supplied to the update a managed application definition. + :type parameters: + ~azure.mgmt.managedapplication.v2018_02_01.models.ApplicationDefinitionPatchable + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ApplicationDefinition, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2018_02_01.models.ApplicationDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationDefinition] + + _json = self._serialize.body(parameters, 'ApplicationDefinitionPatchable') + + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ApplicationDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore + + + @distributed_trace + def list_by_resource_group( + self, + resource_group_name: str, + **kwargs: Any + ) -> Iterable[_models.ApplicationDefinitionListResult]: + """Lists the managed application definitions in a resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ApplicationDefinitionListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.managedapplication.v2018_02_01.models.ApplicationDefinitionListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationDefinitionListResult] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_resource_group.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ApplicationDefinitionListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions"} # type: ignore + + @distributed_trace + def list_by_subscription( + self, + **kwargs: Any + ) -> Iterable[_models.ApplicationDefinitionListResult]: + """Lists the managed application definitions in a subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ApplicationDefinitionListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.managedapplication.v2018_02_01.models.ApplicationDefinitionListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationDefinitionListResult] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ApplicationDefinitionListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Solutions/applicationDefinitions"} # type: ignore + + @distributed_trace + def get_by_id( + self, + resource_group_name: str, + application_definition_name: str, + **kwargs: Any + ) -> Optional[_models.ApplicationDefinition]: + """Gets the managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. + :type application_definition_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ApplicationDefinition, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2018_02_01.models.ApplicationDefinition or None + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.ApplicationDefinition]] + + + request = build_get_by_id_request( + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_by_id.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('ApplicationDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_by_id.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore + + + @distributed_trace + def delete_by_id( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + application_definition_name: str, + **kwargs: Any + ) -> None: + """Deletes the managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. + :type application_definition_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_by_id_request( + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete_by_id.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete_by_id.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore + + + @distributed_trace + def create_or_update_by_id( + self, + resource_group_name: str, + application_definition_name: str, + parameters: _models.ApplicationDefinition, + **kwargs: Any + ) -> _models.ApplicationDefinition: + """Creates or updates a managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. + :type application_definition_name: str + :param parameters: Parameters supplied to the create or update a managed application + definition. + :type parameters: ~azure.mgmt.managedapplication.v2018_02_01.models.ApplicationDefinition + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ApplicationDefinition, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2018_02_01.models.ApplicationDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationDefinition] + + _json = self._serialize.body(parameters, 'ApplicationDefinition') + + request = build_create_or_update_by_id_request( + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + 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'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # 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, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('ApplicationDefinition', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('ApplicationDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_or_update_by_id.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore + + + @distributed_trace + def update_by_id( + self, + resource_group_name: str, + application_definition_name: str, + parameters: _models.ApplicationDefinitionPatchable, + **kwargs: Any + ) -> _models.ApplicationDefinition: + """Updates the managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. + :type application_definition_name: str + :param parameters: Parameters supplied to the update a managed application definition. + :type parameters: + ~azure.mgmt.managedapplication.v2018_02_01.models.ApplicationDefinitionPatchable + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ApplicationDefinition, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2018_02_01.models.ApplicationDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationDefinition] + + _json = self._serialize.body(parameters, 'ApplicationDefinitionPatchable') + + request = build_update_by_id_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.update_by_id.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ApplicationDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + update_by_id.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore + diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_02_01/operations/_applications_operations.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_02_01/operations/_applications_operations.py new file mode 100644 index 000000000000..3ee4b0d9aaf6 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_02_01/operations/_applications_operations.py @@ -0,0 +1,1687 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast + +from msrest import Serializer + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from .._vendor import MixinABC, _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_request( + resource_group_name: str, + application_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "applicationName": _SERIALIZER.url("application_name", application_name, 'str', max_length=64, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_delete_request_initial( + resource_group_name: str, + application_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "applicationName": _SERIALIZER.url("application_name", application_name, 'str', max_length=64, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_create_or_update_request_initial( + resource_group_name: str, + application_name: str, + subscription_id: str, + *, + json: Optional[_models.Application] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "applicationName": _SERIALIZER.url("application_name", application_name, 'str', max_length=64, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_update_request_initial( + resource_group_name: str, + application_name: str, + subscription_id: str, + *, + json: Optional[_models.ApplicationPatchable] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "applicationName": _SERIALIZER.url("application_name", application_name, 'str', max_length=64, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_list_by_resource_group_request( + resource_group_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_list_by_subscription_request( + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Solutions/applications") + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_get_by_id_request( + application_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/{applicationId}") + path_format_arguments = { + "applicationId": _SERIALIZER.url("application_id", application_id, 'str', skip_quote=True), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_delete_by_id_request_initial( + application_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/{applicationId}") + path_format_arguments = { + "applicationId": _SERIALIZER.url("application_id", application_id, 'str', skip_quote=True), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_create_or_update_by_id_request_initial( + application_id: str, + *, + json: Optional[_models.Application] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/{applicationId}") + path_format_arguments = { + "applicationId": _SERIALIZER.url("application_id", application_id, 'str', skip_quote=True), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_update_by_id_request_initial( + application_id: str, + *, + json: Optional[_models.ApplicationPatchable] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/{applicationId}") + path_format_arguments = { + "applicationId": _SERIALIZER.url("application_id", application_id, 'str', skip_quote=True), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_refresh_permissions_request_initial( + resource_group_name: str, + application_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}/refreshPermissions") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "applicationName": _SERIALIZER.url("application_name", application_name, 'str', max_length=64, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + +class ApplicationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.managedapplication.v2018_02_01.ApplicationClient`'s + :attr:`applications` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + + @distributed_trace + def get( + self, + resource_group_name: str, + application_name: str, + **kwargs: Any + ) -> Optional[_models.Application]: + """Gets the managed application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_name: The name of the managed application. + :type application_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Application, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2018_02_01.models.Application or None + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.Application]] + + + request = build_get_request( + resource_group_name=resource_group_name, + application_name=application_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('Application', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}"} # type: ignore + + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + application_name: str, + **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + application_name=application_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}"} # type: ignore + + + @distributed_trace + def begin_delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + application_name: str, + **kwargs: Any + ) -> LROPoller[None]: + """Deletes the managed application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_name: The name of the managed application. + :type application_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._delete_initial( # type: ignore + resource_group_name=resource_group_name, + application_name=application_name, + api_version=api_version, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}"} # type: ignore + + def _create_or_update_initial( + self, + resource_group_name: str, + application_name: str, + parameters: _models.Application, + **kwargs: Any + ) -> _models.Application: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Application] + + _json = self._serialize.body(parameters, 'Application') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + application_name=application_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('Application', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('Application', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}"} # type: ignore + + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + application_name: str, + parameters: _models.Application, + **kwargs: Any + ) -> LROPoller[_models.Application]: + """Creates or updates a managed application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_name: The name of the managed application. + :type application_name: str + :param parameters: Parameters supplied to the create or update a managed application. + :type parameters: ~azure.mgmt.managedapplication.v2018_02_01.models.Application + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Application or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.managedapplication.v2018_02_01.models.Application] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Application] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._create_or_update_initial( # type: ignore + resource_group_name=resource_group_name, + application_name=application_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('Application', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}"} # type: ignore + + def _update_initial( + self, + resource_group_name: str, + application_name: str, + parameters: Optional[_models.ApplicationPatchable] = None, + **kwargs: Any + ) -> _models.ApplicationPatchable: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationPatchable] + + if parameters is not None: + _json = self._serialize.body(parameters, 'ApplicationPatchable') + else: + _json = None + + request = build_update_request_initial( + resource_group_name=resource_group_name, + application_name=application_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('ApplicationPatchable', pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize('ApplicationPatchable', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}"} # type: ignore + + + @distributed_trace + def begin_update( + self, + resource_group_name: str, + application_name: str, + parameters: Optional[_models.ApplicationPatchable] = None, + **kwargs: Any + ) -> LROPoller[_models.ApplicationPatchable]: + """Updates an existing managed application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_name: The name of the managed application. + :type application_name: str + :param parameters: Parameters supplied to update an existing managed application. Default value + is None. + :type parameters: ~azure.mgmt.managedapplication.v2018_02_01.models.ApplicationPatchable + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ApplicationPatchable or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.managedapplication.v2018_02_01.models.ApplicationPatchable] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationPatchable] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._update_initial( # type: ignore + resource_group_name=resource_group_name, + application_name=application_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('ApplicationPatchable', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}"} # type: ignore + + @distributed_trace + def list_by_resource_group( + self, + resource_group_name: str, + **kwargs: Any + ) -> Iterable[_models.ApplicationListResult]: + """Lists all the applications within a resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ApplicationListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.managedapplication.v2018_02_01.models.ApplicationListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationListResult] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_resource_group.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ApplicationListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications"} # type: ignore + + @distributed_trace + def list_by_subscription( + self, + **kwargs: Any + ) -> Iterable[_models.ApplicationListResult]: + """Lists all the applications within a subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ApplicationListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.managedapplication.v2018_02_01.models.ApplicationListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationListResult] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ApplicationListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Solutions/applications"} # type: ignore + + @distributed_trace + def get_by_id( + self, + application_id: str, + **kwargs: Any + ) -> Optional[_models.Application]: + """Gets the managed application. + + :param application_id: The fully qualified ID of the managed application, including the managed + application name and the managed application resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/Microsoft.Solutions/applications/{application-name}. + :type application_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Application, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2018_02_01.models.Application or None + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.Application]] + + + request = build_get_by_id_request( + application_id=application_id, + api_version=api_version, + template_url=self.get_by_id.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('Application', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_by_id.metadata = {'url': "/{applicationId}"} # type: ignore + + + def _delete_by_id_initial( # pylint: disable=inconsistent-return-statements + self, + application_id: str, + **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_by_id_request_initial( + application_id=application_id, + api_version=api_version, + template_url=self._delete_by_id_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_by_id_initial.metadata = {'url': "/{applicationId}"} # type: ignore + + + @distributed_trace + def begin_delete_by_id( # pylint: disable=inconsistent-return-statements + self, + application_id: str, + **kwargs: Any + ) -> LROPoller[None]: + """Deletes the managed application. + + :param application_id: The fully qualified ID of the managed application, including the managed + application name and the managed application resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/Microsoft.Solutions/applications/{application-name}. + :type application_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._delete_by_id_initial( # type: ignore + application_id=application_id, + api_version=api_version, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete_by_id.metadata = {'url': "/{applicationId}"} # type: ignore + + def _create_or_update_by_id_initial( + self, + application_id: str, + parameters: _models.Application, + **kwargs: Any + ) -> _models.Application: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Application] + + _json = self._serialize.body(parameters, 'Application') + + request = build_create_or_update_by_id_request_initial( + application_id=application_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._create_or_update_by_id_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('Application', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('Application', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_by_id_initial.metadata = {'url': "/{applicationId}"} # type: ignore + + + @distributed_trace + def begin_create_or_update_by_id( + self, + application_id: str, + parameters: _models.Application, + **kwargs: Any + ) -> LROPoller[_models.Application]: + """Creates or updates a managed application. + + :param application_id: The fully qualified ID of the managed application, including the managed + application name and the managed application resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/Microsoft.Solutions/applications/{application-name}. + :type application_id: str + :param parameters: Parameters supplied to the create or update a managed application. + :type parameters: ~azure.mgmt.managedapplication.v2018_02_01.models.Application + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Application or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.managedapplication.v2018_02_01.models.Application] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Application] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._create_or_update_by_id_initial( # type: ignore + application_id=application_id, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('Application', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update_by_id.metadata = {'url': "/{applicationId}"} # type: ignore + + def _update_by_id_initial( + self, + application_id: str, + parameters: Optional[_models.ApplicationPatchable] = None, + **kwargs: Any + ) -> _models.ApplicationPatchable: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationPatchable] + + if parameters is not None: + _json = self._serialize.body(parameters, 'ApplicationPatchable') + else: + _json = None + + request = build_update_by_id_request_initial( + application_id=application_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._update_by_id_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('ApplicationPatchable', pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize('ApplicationPatchable', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _update_by_id_initial.metadata = {'url': "/{applicationId}"} # type: ignore + + + @distributed_trace + def begin_update_by_id( + self, + application_id: str, + parameters: Optional[_models.ApplicationPatchable] = None, + **kwargs: Any + ) -> LROPoller[_models.ApplicationPatchable]: + """Updates an existing managed application. + + :param application_id: The fully qualified ID of the managed application, including the managed + application name and the managed application resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/Microsoft.Solutions/applications/{application-name}. + :type application_id: str + :param parameters: Parameters supplied to update an existing managed application. Default value + is None. + :type parameters: ~azure.mgmt.managedapplication.v2018_02_01.models.ApplicationPatchable + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ApplicationPatchable or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.managedapplication.v2018_02_01.models.ApplicationPatchable] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationPatchable] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._update_by_id_initial( # type: ignore + application_id=application_id, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('ApplicationPatchable', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_update_by_id.metadata = {'url': "/{applicationId}"} # type: ignore + + def _refresh_permissions_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + application_name: str, + **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_refresh_permissions_request_initial( + resource_group_name=resource_group_name, + application_name=application_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._refresh_permissions_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _refresh_permissions_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}/refreshPermissions"} # type: ignore + + + @distributed_trace + def begin_refresh_permissions( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + application_name: str, + **kwargs: Any + ) -> LROPoller[None]: + """Refresh Permissions for application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_name: The name of the managed application. + :type application_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._refresh_permissions_initial( # type: ignore + resource_group_name=resource_group_name, + application_name=application_name, + api_version=api_version, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'location'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_refresh_permissions.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}/refreshPermissions"} # type: ignore diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_02_01/operations/_patch.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_02_01/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_02_01/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_02_01/py.typed b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_02_01/py.typed new file mode 100644 index 000000000000..e5aff4f83af8 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_02_01/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_03_01/__init__.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_03_01/__init__.py new file mode 100644 index 000000000000..2e61ca12e56a --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_03_01/__init__.py @@ -0,0 +1,23 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._application_client import ApplicationClient +from ._version import VERSION + +__version__ = VERSION + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk +__all__ = ['ApplicationClient'] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_03_01/_application_client.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_03_01/_application_client.py new file mode 100644 index 000000000000..0fa912510991 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_03_01/_application_client.py @@ -0,0 +1,112 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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 ApplicationClientConfiguration +from .operations import ApplicationClientOperationsMixin, ApplicationDefinitionsOperations, ApplicationsOperations, JitRequestsOperations + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential + +class ApplicationClient(ApplicationClientOperationsMixin): + """ARM applications. + + :ivar applications: ApplicationsOperations operations + :vartype applications: + azure.mgmt.managedapplication.v2018_03_01.operations.ApplicationsOperations + :ivar application_definitions: ApplicationDefinitionsOperations operations + :vartype application_definitions: + azure.mgmt.managedapplication.v2018_03_01.operations.ApplicationDefinitionsOperations + :ivar jit_requests: JitRequestsOperations operations + :vartype jit_requests: + azure.mgmt.managedapplication.v2018_03_01.operations.JitRequestsOperations + :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 "2018-03-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + """ + + def __init__( + self, + credential: "TokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = ApplicationClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.applications = ApplicationsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.application_definitions = ApplicationDefinitionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.jit_requests = JitRequestsOperations( + 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: () -> ApplicationClient + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (Any) -> None + self._client.__exit__(*exc_details) diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_03_01/_configuration.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_03_01/_configuration.py new file mode 100644 index 000000000000..0fd09e201897 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_03_01/_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 ApplicationClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes + """Configuration for ApplicationClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials.TokenCredential + :param subscription_id: The ID of the target subscription. + :type subscription_id: str + :keyword api_version: Api Version. Default value is "2018-03-01". 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(ApplicationClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2018-03-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.") + + 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-managedapplication/{}'.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/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_03_01/_metadata.json b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_03_01/_metadata.json new file mode 100644 index 000000000000..473ae716b37e --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_03_01/_metadata.json @@ -0,0 +1,123 @@ +{ + "chosen_version": "2018-03-01", + "total_api_version_list": ["2018-03-01"], + "client": { + "name": "ApplicationClient", + "filename": "_application_client", + "description": "ARM applications.", + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": null, + "azure_arm": true, + "has_lro_operations": true, + "client_side_validation": false, + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ApplicationClientConfiguration\"], \"._operations_mixin\": [\"ApplicationClientOperationsMixin\"]}, \"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\": [\"ApplicationClientConfiguration\"], \"._operations_mixin\": [\"ApplicationClientOperationsMixin\"]}, \"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": { + "applications": "ApplicationsOperations", + "application_definitions": "ApplicationDefinitionsOperations", + "jit_requests": "JitRequestsOperations" + }, + "operation_mixins": { + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Iterable\"]}, \"azurecore\": {\"azure.core.paging\": [\"ItemPaged\"]}}, \"regular\": {\"local\": {\".\": [[\"models\", \"_models\"]]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"AsyncIterable\"]}, \"azurecore\": {\"azure.core.async_paging\": [\"AsyncItemPaged\"]}}, \"regular\": {\"local\": {\"..\": [[\"models\", \"_models\"]]}}}", + "operations": { + "list_operations" : { + "sync": { + "signature": "def list_operations(\n self,\n **kwargs # type: Any\n):\n # type: (...) -\u003e Iterable[_models.OperationListResult]\n", + "doc": "\"\"\"Lists all of the available Microsoft.Solutions REST API operations.\n\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: An iterator like instance of either OperationListResult or the result of cls(response)\n:rtype:\n ~azure.core.paging.ItemPaged[~azure.mgmt.managedapplication.v2018_03_01.models.OperationListResult]\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"", + "call": "**kwargs" + }, + "async": { + "coroutine": false, + "signature": "def list_operations(\n self,\n **kwargs: Any\n) -\u003e AsyncIterable[_models.OperationListResult]:\n", + "doc": "\"\"\"Lists all of the available Microsoft.Solutions REST API operations.\n\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: An iterator like instance of either OperationListResult or the result of cls(response)\n:rtype:\n ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.managedapplication.v2018_03_01.models.OperationListResult]\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"", + "call": "**kwargs" + } + } + } + } +} \ No newline at end of file diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_03_01/_patch.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_03_01/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_03_01/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_03_01/_vendor.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_03_01/_vendor.py new file mode 100644 index 000000000000..bf1845cabc0f --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_03_01/_vendor.py @@ -0,0 +1,45 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from abc import ABC +from typing import TYPE_CHECKING + +from azure.core.pipeline.transport import HttpRequest + +from ._configuration import ApplicationClientConfiguration + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from msrest import Deserializer, Serializer + + from azure.core import PipelineClient + +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) + +class MixinABC(ABC): + """DO NOT use this class. It is for internal typing use only.""" + _client: "PipelineClient" + _config: ApplicationClientConfiguration + _serialize: "Serializer" + _deserialize: "Deserializer" diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_03_01/_version.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_03_01/_version.py new file mode 100644 index 000000000000..e5754a47ce68 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_03_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/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_03_01/aio/__init__.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_03_01/aio/__init__.py new file mode 100644 index 000000000000..c90626a31421 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_03_01/aio/__init__.py @@ -0,0 +1,20 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._application_client import ApplicationClient + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk +__all__ = ['ApplicationClient'] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_03_01/aio/_application_client.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_03_01/aio/_application_client.py new file mode 100644 index 000000000000..2f476733eb50 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_03_01/aio/_application_client.py @@ -0,0 +1,109 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# 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 ApplicationClientConfiguration +from .operations import ApplicationClientOperationsMixin, ApplicationDefinitionsOperations, ApplicationsOperations, JitRequestsOperations + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + +class ApplicationClient(ApplicationClientOperationsMixin): + """ARM applications. + + :ivar applications: ApplicationsOperations operations + :vartype applications: + azure.mgmt.managedapplication.v2018_03_01.aio.operations.ApplicationsOperations + :ivar application_definitions: ApplicationDefinitionsOperations operations + :vartype application_definitions: + azure.mgmt.managedapplication.v2018_03_01.aio.operations.ApplicationDefinitionsOperations + :ivar jit_requests: JitRequestsOperations operations + :vartype jit_requests: + azure.mgmt.managedapplication.v2018_03_01.aio.operations.JitRequestsOperations + :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 "2018-03-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = ApplicationClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.applications = ApplicationsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.application_definitions = ApplicationDefinitionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.jit_requests = JitRequestsOperations( + 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) -> "ApplicationClient": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_03_01/aio/_configuration.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_03_01/aio/_configuration.py new file mode 100644 index 000000000000..f8ad7b4faf18 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_03_01/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 ApplicationClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes + """Configuration for ApplicationClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :param subscription_id: The ID of the target subscription. + :type subscription_id: str + :keyword api_version: Api Version. Default value is "2018-03-01". 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(ApplicationClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2018-03-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.") + + 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-managedapplication/{}'.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/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_03_01/aio/_patch.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_03_01/aio/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_03_01/aio/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_03_01/aio/_vendor.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_03_01/aio/_vendor.py new file mode 100644 index 000000000000..da14e4f71f0e --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_03_01/aio/_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 abc import ABC +from typing import TYPE_CHECKING + +from azure.core.pipeline.transport import HttpRequest + +from ._configuration import ApplicationClientConfiguration + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from msrest import Deserializer, Serializer + + from azure.core import AsyncPipelineClient + + +class MixinABC(ABC): + """DO NOT use this class. It is for internal typing use only.""" + _client: "AsyncPipelineClient" + _config: ApplicationClientConfiguration + _serialize: "Serializer" + _deserialize: "Deserializer" diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_03_01/aio/operations/__init__.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_03_01/aio/operations/__init__.py new file mode 100644 index 000000000000..b93ecbbe65e2 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_03_01/aio/operations/__init__.py @@ -0,0 +1,24 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._application_client_operations import ApplicationClientOperationsMixin +from ._applications_operations import ApplicationsOperations +from ._application_definitions_operations import ApplicationDefinitionsOperations +from ._jit_requests_operations import JitRequestsOperations + +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk +__all__ = [ + 'ApplicationClientOperationsMixin', + 'ApplicationsOperations', + 'ApplicationDefinitionsOperations', + 'JitRequestsOperations', +] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_03_01/aio/operations/_application_client_operations.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_03_01/aio/operations/_application_client_operations.py new file mode 100644 index 000000000000..264212966774 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_03_01/aio/operations/_application_client_operations.py @@ -0,0 +1,105 @@ +# 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.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._application_client_operations import build_list_operations_request +from .._vendor import MixinABC +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class ApplicationClientOperationsMixin(MixinABC): + + @distributed_trace + def list_operations( + self, + **kwargs: Any + ) -> AsyncIterable[_models.OperationListResult]: + """Lists all of the available Microsoft.Solutions REST API operations. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either OperationListResult or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.managedapplication.v2018_03_01.models.OperationListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01")) # 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', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_operations_request( + api_version=api_version, + template_url=self.list_operations.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_operations_request( + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list_operations.metadata = {'url': "/providers/Microsoft.Solutions/operations"} # type: ignore diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_03_01/aio/operations/_application_definitions_operations.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_03_01/aio/operations/_application_definitions_operations.py new file mode 100644 index 000000000000..eee920bcc999 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_03_01/aio/operations/_application_definitions_operations.py @@ -0,0 +1,761 @@ +# 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.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._application_definitions_operations import build_create_or_update_by_id_request, build_create_or_update_request, build_delete_by_id_request, build_delete_request, build_get_by_id_request, build_get_request, build_list_by_resource_group_request, build_list_by_subscription_request, build_update_by_id_request, build_update_request +from .._vendor import MixinABC +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class ApplicationDefinitionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.managedapplication.v2018_03_01.aio.ApplicationClient`'s + :attr:`application_definitions` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + application_definition_name: str, + **kwargs: Any + ) -> Optional[_models.ApplicationDefinition]: + """Gets the managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. + :type application_definition_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ApplicationDefinition, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2018_03_01.models.ApplicationDefinition or None + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.ApplicationDefinition]] + + + request = build_get_request( + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('ApplicationDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore + + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + application_definition_name: str, + **kwargs: Any + ) -> None: + """Deletes the managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition to delete. + :type application_definition_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_request( + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore + + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + application_definition_name: str, + parameters: _models.ApplicationDefinition, + **kwargs: Any + ) -> _models.ApplicationDefinition: + """Creates or update a managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. + :type application_definition_name: str + :param parameters: Parameters supplied to the create or update an managed application + definition. + :type parameters: ~azure.mgmt.managedapplication.v2018_03_01.models.ApplicationDefinition + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ApplicationDefinition, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2018_03_01.models.ApplicationDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationDefinition] + + _json = self._serialize.body(parameters, 'ApplicationDefinition') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # 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, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('ApplicationDefinition', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('ApplicationDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore + + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + application_definition_name: str, + parameters: _models.ApplicationDefinitionPatchable, + **kwargs: Any + ) -> _models.ApplicationDefinition: + """Updates the managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. + :type application_definition_name: str + :param parameters: Parameters supplied to the update a managed application definition. + :type parameters: + ~azure.mgmt.managedapplication.v2018_03_01.models.ApplicationDefinitionPatchable + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ApplicationDefinition, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2018_03_01.models.ApplicationDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationDefinition] + + _json = self._serialize.body(parameters, 'ApplicationDefinitionPatchable') + + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ApplicationDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore + + + @distributed_trace + def list_by_resource_group( + self, + resource_group_name: str, + **kwargs: Any + ) -> AsyncIterable[_models.ApplicationDefinitionListResult]: + """Lists the managed application definitions in a resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ApplicationDefinitionListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.managedapplication.v2018_03_01.models.ApplicationDefinitionListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationDefinitionListResult] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_resource_group.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ApplicationDefinitionListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions"} # type: ignore + + @distributed_trace + def list_by_subscription( + self, + **kwargs: Any + ) -> AsyncIterable[_models.ApplicationDefinitionListResult]: + """Lists the managed application definitions in a subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ApplicationDefinitionListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.managedapplication.v2018_03_01.models.ApplicationDefinitionListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationDefinitionListResult] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ApplicationDefinitionListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Solutions/applicationDefinitions"} # type: ignore + + @distributed_trace_async + async def get_by_id( + self, + resource_group_name: str, + application_definition_name: str, + **kwargs: Any + ) -> Optional[_models.ApplicationDefinition]: + """Gets the managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. + :type application_definition_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ApplicationDefinition, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2018_03_01.models.ApplicationDefinition or None + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.ApplicationDefinition]] + + + request = build_get_by_id_request( + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_by_id.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('ApplicationDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_by_id.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore + + + @distributed_trace_async + async def delete_by_id( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + application_definition_name: str, + **kwargs: Any + ) -> None: + """Deletes the managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. + :type application_definition_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_by_id_request( + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete_by_id.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete_by_id.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore + + + @distributed_trace_async + async def create_or_update_by_id( + self, + resource_group_name: str, + application_definition_name: str, + parameters: _models.ApplicationDefinition, + **kwargs: Any + ) -> _models.ApplicationDefinition: + """Creates or updates a managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. + :type application_definition_name: str + :param parameters: Parameters supplied to the create or update a managed application + definition. + :type parameters: ~azure.mgmt.managedapplication.v2018_03_01.models.ApplicationDefinition + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ApplicationDefinition, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2018_03_01.models.ApplicationDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationDefinition] + + _json = self._serialize.body(parameters, 'ApplicationDefinition') + + request = build_create_or_update_by_id_request( + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + 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'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # 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, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('ApplicationDefinition', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('ApplicationDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_or_update_by_id.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore + + + @distributed_trace_async + async def update_by_id( + self, + resource_group_name: str, + application_definition_name: str, + parameters: _models.ApplicationDefinitionPatchable, + **kwargs: Any + ) -> _models.ApplicationDefinition: + """Updates the managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. + :type application_definition_name: str + :param parameters: Parameters supplied to the update a managed application definition. + :type parameters: + ~azure.mgmt.managedapplication.v2018_03_01.models.ApplicationDefinitionPatchable + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ApplicationDefinition, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2018_03_01.models.ApplicationDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationDefinition] + + _json = self._serialize.body(parameters, 'ApplicationDefinitionPatchable') + + request = build_update_by_id_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.update_by_id.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ApplicationDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + update_by_id.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore + diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_03_01/aio/operations/_applications_operations.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_03_01/aio/operations/_applications_operations.py new file mode 100644 index 000000000000..ce7f3a63a55e --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_03_01/aio/operations/_applications_operations.py @@ -0,0 +1,1481 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union, cast + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._applications_operations import build_create_or_update_by_id_request_initial, build_create_or_update_request_initial, build_delete_by_id_request_initial, build_delete_request_initial, build_get_by_id_request, build_get_request, build_list_by_resource_group_request, build_list_by_subscription_request, build_list_tokens_request, build_refresh_permissions_request_initial, build_update_access_request_initial, build_update_by_id_request_initial, build_update_request_initial +from .._vendor import MixinABC +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class ApplicationsOperations: # pylint: disable=too-many-public-methods + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.managedapplication.v2018_03_01.aio.ApplicationClient`'s + :attr:`applications` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + application_name: str, + **kwargs: Any + ) -> Optional[_models.Application]: + """Gets the managed application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_name: The name of the managed application. + :type application_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Application, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2018_03_01.models.Application or None + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.Application]] + + + request = build_get_request( + resource_group_name=resource_group_name, + application_name=application_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('Application', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}"} # type: ignore + + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + application_name: str, + **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + application_name=application_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}"} # type: ignore + + + @distributed_trace_async + async def begin_delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + application_name: str, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes the managed application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_name: The name of the managed application. + :type application_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._delete_initial( # type: ignore + resource_group_name=resource_group_name, + application_name=application_name, + api_version=api_version, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}"} # type: ignore + + async def _create_or_update_initial( + self, + resource_group_name: str, + application_name: str, + parameters: _models.Application, + **kwargs: Any + ) -> _models.Application: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Application] + + _json = self._serialize.body(parameters, 'Application') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + application_name=application_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('Application', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('Application', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}"} # type: ignore + + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + application_name: str, + parameters: _models.Application, + **kwargs: Any + ) -> AsyncLROPoller[_models.Application]: + """Creates or updates a managed application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_name: The name of the managed application. + :type application_name: str + :param parameters: Parameters supplied to the create or update a managed application. + :type parameters: ~azure.mgmt.managedapplication.v2018_03_01.models.Application + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either Application or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.managedapplication.v2018_03_01.models.Application] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Application] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._create_or_update_initial( # type: ignore + resource_group_name=resource_group_name, + application_name=application_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('Application', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}"} # type: ignore + + async def _update_initial( + self, + resource_group_name: str, + application_name: str, + parameters: Optional[_models.ApplicationPatchable] = None, + **kwargs: Any + ) -> _models.ApplicationPatchable: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationPatchable] + + if parameters is not None: + _json = self._serialize.body(parameters, 'ApplicationPatchable') + else: + _json = None + + request = build_update_request_initial( + resource_group_name=resource_group_name, + application_name=application_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('ApplicationPatchable', pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize('ApplicationPatchable', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}"} # type: ignore + + + @distributed_trace_async + async def begin_update( + self, + resource_group_name: str, + application_name: str, + parameters: Optional[_models.ApplicationPatchable] = None, + **kwargs: Any + ) -> AsyncLROPoller[_models.ApplicationPatchable]: + """Updates an existing managed application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_name: The name of the managed application. + :type application_name: str + :param parameters: Parameters supplied to update an existing managed application. Default value + is None. + :type parameters: ~azure.mgmt.managedapplication.v2018_03_01.models.ApplicationPatchable + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ApplicationPatchable or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.managedapplication.v2018_03_01.models.ApplicationPatchable] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationPatchable] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._update_initial( # type: ignore + resource_group_name=resource_group_name, + application_name=application_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('ApplicationPatchable', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}"} # type: ignore + + @distributed_trace + def list_by_resource_group( + self, + resource_group_name: str, + **kwargs: Any + ) -> AsyncIterable[_models.ApplicationListResult]: + """Lists all the applications within a resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ApplicationListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.managedapplication.v2018_03_01.models.ApplicationListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationListResult] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_resource_group.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ApplicationListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications"} # type: ignore + + @distributed_trace + def list_by_subscription( + self, + **kwargs: Any + ) -> AsyncIterable[_models.ApplicationListResult]: + """Lists all the applications within a subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ApplicationListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.managedapplication.v2018_03_01.models.ApplicationListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationListResult] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ApplicationListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Solutions/applications"} # type: ignore + + @distributed_trace_async + async def get_by_id( + self, + application_id: str, + **kwargs: Any + ) -> Optional[_models.Application]: + """Gets the managed application. + + :param application_id: The fully qualified ID of the managed application, including the managed + application name and the managed application resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/Microsoft.Solutions/applications/{application-name}. + :type application_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Application, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2018_03_01.models.Application or None + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.Application]] + + + request = build_get_by_id_request( + application_id=application_id, + api_version=api_version, + template_url=self.get_by_id.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('Application', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_by_id.metadata = {'url': "/{applicationId}"} # type: ignore + + + async def _delete_by_id_initial( # pylint: disable=inconsistent-return-statements + self, + application_id: str, + **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_by_id_request_initial( + application_id=application_id, + api_version=api_version, + template_url=self._delete_by_id_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_by_id_initial.metadata = {'url': "/{applicationId}"} # type: ignore + + + @distributed_trace_async + async def begin_delete_by_id( # pylint: disable=inconsistent-return-statements + self, + application_id: str, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes the managed application. + + :param application_id: The fully qualified ID of the managed application, including the managed + application name and the managed application resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/Microsoft.Solutions/applications/{application-name}. + :type application_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._delete_by_id_initial( # type: ignore + application_id=application_id, + api_version=api_version, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete_by_id.metadata = {'url': "/{applicationId}"} # type: ignore + + async def _create_or_update_by_id_initial( + self, + application_id: str, + parameters: _models.Application, + **kwargs: Any + ) -> _models.Application: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Application] + + _json = self._serialize.body(parameters, 'Application') + + request = build_create_or_update_by_id_request_initial( + application_id=application_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._create_or_update_by_id_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('Application', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('Application', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_by_id_initial.metadata = {'url': "/{applicationId}"} # type: ignore + + + @distributed_trace_async + async def begin_create_or_update_by_id( + self, + application_id: str, + parameters: _models.Application, + **kwargs: Any + ) -> AsyncLROPoller[_models.Application]: + """Creates or updates a managed application. + + :param application_id: The fully qualified ID of the managed application, including the managed + application name and the managed application resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/Microsoft.Solutions/applications/{application-name}. + :type application_id: str + :param parameters: Parameters supplied to the create or update a managed application. + :type parameters: ~azure.mgmt.managedapplication.v2018_03_01.models.Application + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either Application or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.managedapplication.v2018_03_01.models.Application] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Application] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._create_or_update_by_id_initial( # type: ignore + application_id=application_id, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('Application', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update_by_id.metadata = {'url': "/{applicationId}"} # type: ignore + + async def _update_by_id_initial( + self, + application_id: str, + parameters: Optional[_models.ApplicationPatchable] = None, + **kwargs: Any + ) -> _models.ApplicationPatchable: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationPatchable] + + if parameters is not None: + _json = self._serialize.body(parameters, 'ApplicationPatchable') + else: + _json = None + + request = build_update_by_id_request_initial( + application_id=application_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._update_by_id_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('ApplicationPatchable', pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize('ApplicationPatchable', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _update_by_id_initial.metadata = {'url': "/{applicationId}"} # type: ignore + + + @distributed_trace_async + async def begin_update_by_id( + self, + application_id: str, + parameters: Optional[_models.ApplicationPatchable] = None, + **kwargs: Any + ) -> AsyncLROPoller[_models.ApplicationPatchable]: + """Updates an existing managed application. + + :param application_id: The fully qualified ID of the managed application, including the managed + application name and the managed application resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/Microsoft.Solutions/applications/{application-name}. + :type application_id: str + :param parameters: Parameters supplied to update an existing managed application. Default value + is None. + :type parameters: ~azure.mgmt.managedapplication.v2018_03_01.models.ApplicationPatchable + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ApplicationPatchable or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.managedapplication.v2018_03_01.models.ApplicationPatchable] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationPatchable] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._update_by_id_initial( # type: ignore + application_id=application_id, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('ApplicationPatchable', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_update_by_id.metadata = {'url': "/{applicationId}"} # type: ignore + + async def _refresh_permissions_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + application_name: str, + **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_refresh_permissions_request_initial( + resource_group_name=resource_group_name, + application_name=application_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._refresh_permissions_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _refresh_permissions_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}/refreshPermissions"} # type: ignore + + + @distributed_trace_async + async def begin_refresh_permissions( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + application_name: str, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Refresh Permissions for application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_name: The name of the managed application. + :type application_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._refresh_permissions_initial( # type: ignore + resource_group_name=resource_group_name, + application_name=application_name, + api_version=api_version, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'location'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_refresh_permissions.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}/refreshPermissions"} # type: ignore + + async def _update_access_initial( + self, + resource_group_name: str, + application_name: str, + parameters: _models.UpdateAccessDefinition, + **kwargs: Any + ) -> Optional[_models.UpdateAccessDefinition]: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.UpdateAccessDefinition]] + + _json = self._serialize.body(parameters, 'UpdateAccessDefinition') + + request = build_update_access_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + application_name=application_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._update_access_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 202: + deserialized = self._deserialize('UpdateAccessDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _update_access_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}/updateAccess"} # type: ignore + + + @distributed_trace_async + async def begin_update_access( + self, + resource_group_name: str, + application_name: str, + parameters: _models.UpdateAccessDefinition, + **kwargs: Any + ) -> AsyncLROPoller[_models.UpdateAccessDefinition]: + """Update access for application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_name: The name of the managed application. + :type application_name: str + :param parameters: Request body parameters to update access. + :type parameters: ~azure.mgmt.managedapplication.v2018_03_01.models.UpdateAccessDefinition + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either UpdateAccessDefinition or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.managedapplication.v2018_03_01.models.UpdateAccessDefinition] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.UpdateAccessDefinition] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._update_access_initial( # type: ignore + resource_group_name=resource_group_name, + application_name=application_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('UpdateAccessDefinition', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'location'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_update_access.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}/updateAccess"} # type: ignore + + @distributed_trace_async + async def list_tokens( + self, + resource_group_name: str, + application_name: str, + parameters: _models.ListTokenRequest, + **kwargs: Any + ) -> _models.ManagedIdentityTokenResult: + """List tokens for application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_name: The name of the managed application. + :type application_name: str + :param parameters: Request body parameters to list tokens. + :type parameters: ~azure.mgmt.managedapplication.v2018_03_01.models.ListTokenRequest + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ManagedIdentityTokenResult, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2018_03_01.models.ManagedIdentityTokenResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ManagedIdentityTokenResult] + + _json = self._serialize.body(parameters, 'ListTokenRequest') + + request = build_list_tokens_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + application_name=application_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.list_tokens.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ManagedIdentityTokenResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_tokens.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}/listTokens"} # type: ignore + diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_03_01/aio/operations/_jit_requests_operations.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_03_01/aio/operations/_jit_requests_operations.py new file mode 100644 index 000000000000..032285552330 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_03_01/aio/operations/_jit_requests_operations.py @@ -0,0 +1,502 @@ +# 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, Union, cast + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._jit_requests_operations import build_create_or_update_request_initial, build_delete_request, build_get_request, build_list_by_resource_group_request, build_list_by_subscription_request, build_update_request +from .._vendor import MixinABC +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class JitRequestsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.managedapplication.v2018_03_01.aio.ApplicationClient`'s + :attr:`jit_requests` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + jit_request_name: str, + **kwargs: Any + ) -> Optional[_models.JitRequestDefinition]: + """Gets the JIT request. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param jit_request_name: The name of the JIT request. + :type jit_request_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JitRequestDefinition, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2018_03_01.models.JitRequestDefinition or None + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.JitRequestDefinition]] + + + request = build_get_request( + resource_group_name=resource_group_name, + jit_request_name=jit_request_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('JitRequestDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/jitRequests/{jitRequestName}"} # type: ignore + + + async def _create_or_update_initial( + self, + resource_group_name: str, + jit_request_name: str, + parameters: _models.JitRequestDefinition, + **kwargs: Any + ) -> _models.JitRequestDefinition: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.JitRequestDefinition] + + _json = self._serialize.body(parameters, 'JitRequestDefinition') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + jit_request_name=jit_request_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('JitRequestDefinition', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('JitRequestDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/jitRequests/{jitRequestName}"} # type: ignore + + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + jit_request_name: str, + parameters: _models.JitRequestDefinition, + **kwargs: Any + ) -> AsyncLROPoller[_models.JitRequestDefinition]: + """Creates or updates the JIT request. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param jit_request_name: The name of the JIT request. + :type jit_request_name: str + :param parameters: Parameters supplied to the update JIT request. + :type parameters: ~azure.mgmt.managedapplication.v2018_03_01.models.JitRequestDefinition + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either JitRequestDefinition or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.managedapplication.v2018_03_01.models.JitRequestDefinition] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.JitRequestDefinition] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._create_or_update_initial( # type: ignore + resource_group_name=resource_group_name, + jit_request_name=jit_request_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('JitRequestDefinition', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/jitRequests/{jitRequestName}"} # type: ignore + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + jit_request_name: str, + parameters: _models.JitRequestPatchable, + **kwargs: Any + ) -> _models.JitRequestDefinition: + """Updates the JIT request. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param jit_request_name: The name of the JIT request. + :type jit_request_name: str + :param parameters: Parameters supplied to the update JIT request. + :type parameters: ~azure.mgmt.managedapplication.v2018_03_01.models.JitRequestPatchable + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JitRequestDefinition, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2018_03_01.models.JitRequestDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.JitRequestDefinition] + + _json = self._serialize.body(parameters, 'JitRequestPatchable') + + request = build_update_request( + resource_group_name=resource_group_name, + jit_request_name=jit_request_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('JitRequestDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/jitRequests/{jitRequestName}"} # type: ignore + + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + jit_request_name: str, + **kwargs: Any + ) -> None: + """Deletes the JIT request. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param jit_request_name: The name of the JIT request. + :type jit_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 + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_request( + resource_group_name=resource_group_name, + jit_request_name=jit_request_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/jitRequests/{jitRequestName}"} # type: ignore + + + @distributed_trace_async + async def list_by_subscription( + self, + **kwargs: Any + ) -> _models.JitRequestDefinitionListResult: + """Lists all JIT requests within the subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JitRequestDefinitionListResult, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2018_03_01.models.JitRequestDefinitionListResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.JitRequestDefinitionListResult] + + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('JitRequestDefinitionListResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Solutions/jitRequests"} # type: ignore + + + @distributed_trace_async + async def list_by_resource_group( + self, + resource_group_name: str, + **kwargs: Any + ) -> _models.JitRequestDefinitionListResult: + """Lists all JIT requests within the 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: JitRequestDefinitionListResult, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2018_03_01.models.JitRequestDefinitionListResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.JitRequestDefinitionListResult] + + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_resource_group.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('JitRequestDefinitionListResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/jitRequests"} # type: ignore + diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_03_01/aio/operations/_patch.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_03_01/aio/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_03_01/aio/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_03_01/models/__init__.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_03_01/models/__init__.py new file mode 100644 index 000000000000..ef4ce00645c2 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_03_01/models/__init__.py @@ -0,0 +1,135 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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 Application +from ._models_py3 import ApplicationArtifact +from ._models_py3 import ApplicationAuthorization +from ._models_py3 import ApplicationBillingDetailsDefinition +from ._models_py3 import ApplicationClientDetails +from ._models_py3 import ApplicationDefinition +from ._models_py3 import ApplicationDefinitionArtifact +from ._models_py3 import ApplicationDefinitionListResult +from ._models_py3 import ApplicationDefinitionPatchable +from ._models_py3 import ApplicationJitAccessPolicy +from ._models_py3 import ApplicationListResult +from ._models_py3 import ApplicationPackageContact +from ._models_py3 import ApplicationPackageSupportUrls +from ._models_py3 import ApplicationPatchable +from ._models_py3 import ApplicationPolicy +from ._models_py3 import ApplicationPropertiesPatchable +from ._models_py3 import ErrorAdditionalInfo +from ._models_py3 import ErrorDetail +from ._models_py3 import ErrorResponse +from ._models_py3 import GenericResource +from ._models_py3 import Identity +from ._models_py3 import JitApproverDefinition +from ._models_py3 import JitAuthorizationPolicies +from ._models_py3 import JitRequestDefinition +from ._models_py3 import JitRequestDefinitionListResult +from ._models_py3 import JitRequestMetadata +from ._models_py3 import JitRequestPatchable +from ._models_py3 import JitSchedulingPolicy +from ._models_py3 import ListTokenRequest +from ._models_py3 import ManagedIdentityToken +from ._models_py3 import ManagedIdentityTokenResult +from ._models_py3 import Operation +from ._models_py3 import OperationAutoGenerated +from ._models_py3 import OperationDisplay +from ._models_py3 import OperationDisplayAutoGenerated +from ._models_py3 import OperationListResult +from ._models_py3 import Plan +from ._models_py3 import PlanPatchable +from ._models_py3 import Resource +from ._models_py3 import Sku +from ._models_py3 import UpdateAccessDefinition +from ._models_py3 import UserAssignedResourceIdentity + + +from ._application_client_enums import ( + ActionType, + ApplicationArtifactName, + ApplicationArtifactType, + ApplicationDefinitionArtifactName, + ApplicationLockLevel, + ApplicationManagementMode, + DeploymentMode, + JitApprovalMode, + JitApproverType, + JitRequestState, + JitSchedulingType, + Origin, + ProvisioningState, + ResourceIdentityType, + Status, + Substatus, +) +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk +__all__ = [ + 'Application', + 'ApplicationArtifact', + 'ApplicationAuthorization', + 'ApplicationBillingDetailsDefinition', + 'ApplicationClientDetails', + 'ApplicationDefinition', + 'ApplicationDefinitionArtifact', + 'ApplicationDefinitionListResult', + 'ApplicationDefinitionPatchable', + 'ApplicationJitAccessPolicy', + 'ApplicationListResult', + 'ApplicationPackageContact', + 'ApplicationPackageSupportUrls', + 'ApplicationPatchable', + 'ApplicationPolicy', + 'ApplicationPropertiesPatchable', + 'ErrorAdditionalInfo', + 'ErrorDetail', + 'ErrorResponse', + 'GenericResource', + 'Identity', + 'JitApproverDefinition', + 'JitAuthorizationPolicies', + 'JitRequestDefinition', + 'JitRequestDefinitionListResult', + 'JitRequestMetadata', + 'JitRequestPatchable', + 'JitSchedulingPolicy', + 'ListTokenRequest', + 'ManagedIdentityToken', + 'ManagedIdentityTokenResult', + 'Operation', + 'OperationAutoGenerated', + 'OperationDisplay', + 'OperationDisplayAutoGenerated', + 'OperationListResult', + 'Plan', + 'PlanPatchable', + 'Resource', + 'Sku', + 'UpdateAccessDefinition', + 'UserAssignedResourceIdentity', + 'ActionType', + 'ApplicationArtifactName', + 'ApplicationArtifactType', + 'ApplicationDefinitionArtifactName', + 'ApplicationLockLevel', + 'ApplicationManagementMode', + 'DeploymentMode', + 'JitApprovalMode', + 'JitApproverType', + 'JitRequestState', + 'JitSchedulingType', + 'Origin', + 'ProvisioningState', + 'ResourceIdentityType', + 'Status', + 'Substatus', +] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_03_01/models/_application_client_enums.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_03_01/models/_application_client_enums.py new file mode 100644 index 000000000000..890f1a84757e --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_03_01/models/_application_client_enums.py @@ -0,0 +1,157 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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 azure.core import CaseInsensitiveEnumMeta + + +class ActionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. + """ + + INTERNAL = "Internal" + +class ApplicationArtifactName(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The managed application artifact name. + """ + + NOT_SPECIFIED = "NotSpecified" + VIEW_DEFINITION = "ViewDefinition" + AUTHORIZATIONS = "Authorizations" + CUSTOM_ROLE_DEFINITION = "CustomRoleDefinition" + +class ApplicationArtifactType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The managed application artifact type. + """ + + NOT_SPECIFIED = "NotSpecified" + TEMPLATE = "Template" + CUSTOM = "Custom" + +class ApplicationDefinitionArtifactName(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The managed application artifact name. + """ + + NOT_SPECIFIED = "NotSpecified" + APPLICATION_RESOURCE_TEMPLATE = "ApplicationResourceTemplate" + CREATE_UI_DEFINITION = "CreateUiDefinition" + MAIN_TEMPLATE_PARAMETERS = "MainTemplateParameters" + +class ApplicationLockLevel(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The managed application lock level. + """ + + CAN_NOT_DELETE = "CanNotDelete" + READ_ONLY = "ReadOnly" + NONE = "None" + +class ApplicationManagementMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The management mode. + """ + + NOT_SPECIFIED = "NotSpecified" + UNMANAGED = "Unmanaged" + MANAGED = "Managed" + +class DeploymentMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The deployment mode. + """ + + NOT_SPECIFIED = "NotSpecified" + INCREMENTAL = "Incremental" + COMPLETE = "Complete" + +class JitApprovalMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The Jit approval mode. + """ + + NOT_SPECIFIED = "NotSpecified" + AUTO_APPROVE = "AutoApprove" + MANUAL_APPROVE = "ManualApprove" + +class JitApproverType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The approver type. + """ + + USER = "user" + GROUP = "group" + +class JitRequestState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The JIT request state. + """ + + NOT_SPECIFIED = "NotSpecified" + PENDING = "Pending" + APPROVED = "Approved" + DENIED = "Denied" + FAILED = "Failed" + CANCELED = "Canceled" + EXPIRED = "Expired" + TIMEOUT = "Timeout" + +class JitSchedulingType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The JIT request scheduling type. + """ + + NOT_SPECIFIED = "NotSpecified" + ONCE = "Once" + RECURRING = "Recurring" + +class Origin(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit + logs UX. Default value is "user,system" + """ + + USER = "user" + SYSTEM = "system" + USER_SYSTEM = "user,system" + +class ProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Provisioning status of the managed application. + """ + + NOT_SPECIFIED = "NotSpecified" + ACCEPTED = "Accepted" + RUNNING = "Running" + READY = "Ready" + CREATING = "Creating" + CREATED = "Created" + DELETING = "Deleting" + DELETED = "Deleted" + CANCELED = "Canceled" + FAILED = "Failed" + SUCCEEDED = "Succeeded" + UPDATING = "Updating" + +class ResourceIdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The identity type. + """ + + SYSTEM_ASSIGNED = "SystemAssigned" + USER_ASSIGNED = "UserAssigned" + SYSTEM_ASSIGNED_USER_ASSIGNED = "SystemAssigned, UserAssigned" + NONE = "None" + +class Status(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The JIT status. + """ + + NOT_SPECIFIED = "NotSpecified" + ELEVATE = "Elevate" + REMOVE = "Remove" + +class Substatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The sub status. + """ + + NOT_SPECIFIED = "NotSpecified" + APPROVED = "Approved" + DENIED = "Denied" + FAILED = "Failed" + EXPIRED = "Expired" + TIMEOUT = "Timeout" diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_03_01/models/_models_py3.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_03_01/models/_models_py3.py new file mode 100644 index 000000000000..7917330dad13 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_03_01/models/_models_py3.py @@ -0,0 +1,2298 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for 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 Any, Dict, List, Optional, TYPE_CHECKING, Union + +from azure.core.exceptions import HttpResponseError +import msrest.serialization + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + import __init__ as _models + + +class Resource(msrest.serialization.Model): + """Resource information. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Resource ID. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar location: Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'location': {'key': 'location', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + } + + def __init__( + self, + *, + location: Optional[str] = None, + tags: Optional[Dict[str, str]] = None, + **kwargs + ): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + """ + super(Resource, self).__init__(**kwargs) + self.id = None + self.name = None + self.type = None + self.location = location + self.tags = tags + + +class GenericResource(Resource): + """Resource information. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Resource ID. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar location: Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar managed_by: ID of the resource that manages this resource. + :vartype managed_by: str + :ivar sku: The SKU of the resource. + :vartype sku: ~azure.mgmt.managedapplication.v2018_03_01.models.Sku + """ + + _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'}, + 'location': {'key': 'location', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + 'managed_by': {'key': 'managedBy', 'type': 'str'}, + 'sku': {'key': 'sku', 'type': 'Sku'}, + } + + def __init__( + self, + *, + location: Optional[str] = None, + tags: Optional[Dict[str, str]] = None, + managed_by: Optional[str] = None, + sku: Optional["_models.Sku"] = None, + **kwargs + ): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword managed_by: ID of the resource that manages this resource. + :paramtype managed_by: str + :keyword sku: The SKU of the resource. + :paramtype sku: ~azure.mgmt.managedapplication.v2018_03_01.models.Sku + """ + super(GenericResource, self).__init__(location=location, tags=tags, **kwargs) + self.managed_by = managed_by + self.sku = sku + + +class Application(GenericResource): + """Information about managed application. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar id: Resource ID. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar location: Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar managed_by: ID of the resource that manages this resource. + :vartype managed_by: str + :ivar sku: The SKU of the resource. + :vartype sku: ~azure.mgmt.managedapplication.v2018_03_01.models.Sku + :ivar plan: The plan information. + :vartype plan: ~azure.mgmt.managedapplication.v2018_03_01.models.Plan + :ivar kind: Required. The kind of the managed application. Allowed values are MarketPlace and + ServiceCatalog. + :vartype kind: str + :ivar identity: The identity of the resource. + :vartype identity: ~azure.mgmt.managedapplication.v2018_03_01.models.Identity + :ivar managed_resource_group_id: The managed resource group Id. + :vartype managed_resource_group_id: str + :ivar application_definition_id: The fully qualified path of managed application definition Id. + :vartype application_definition_id: str + :ivar publisher_package_id: The publisher package Id. + :vartype publisher_package_id: str + :ivar parameters: Name and value pairs that define the managed application parameters. It can + be a JObject or a well formed JSON string. + :vartype parameters: any + :ivar outputs: Name and value pairs that define the managed application outputs. + :vartype outputs: any + :ivar provisioning_state: The managed application provisioning state. Known values are: + "NotSpecified", "Accepted", "Running", "Ready", "Creating", "Created", "Deleting", "Deleted", + "Canceled", "Failed", "Succeeded", "Updating". + :vartype provisioning_state: str or + ~azure.mgmt.managedapplication.v2018_03_01.models.ProvisioningState + :ivar billing_details: The managed application billing details. + :vartype billing_details: + ~azure.mgmt.managedapplication.v2018_03_01.models.ApplicationBillingDetailsDefinition + :ivar jit_access_policy: The managed application Jit access policy. + :vartype jit_access_policy: + ~azure.mgmt.managedapplication.v2018_03_01.models.ApplicationJitAccessPolicy + :ivar publisher_tenant_id: The publisher tenant Id. + :vartype publisher_tenant_id: str + :ivar authorizations: The read-only authorizations property that is retrieved from the + application package. + :vartype authorizations: + list[~azure.mgmt.managedapplication.v2018_03_01.models.ApplicationAuthorization] + :ivar customer_support: The read-only customer support property that is retrieved from the + application package. + :vartype customer_support: + ~azure.mgmt.managedapplication.v2018_03_01.models.ApplicationPackageContact + :ivar support_urls: The read-only support URLs property that is retrieved from the application + package. + :vartype support_urls: + ~azure.mgmt.managedapplication.v2018_03_01.models.ApplicationPackageSupportUrls + :ivar artifacts: The collection of managed application artifacts. + :vartype artifacts: list[~azure.mgmt.managedapplication.v2018_03_01.models.ApplicationArtifact] + :ivar created_by: The client entity that created the JIT request. + :vartype created_by: ~azure.mgmt.managedapplication.v2018_03_01.models.ApplicationClientDetails + :ivar updated_by: The client entity that last updated the JIT request. + :vartype updated_by: ~azure.mgmt.managedapplication.v2018_03_01.models.ApplicationClientDetails + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'kind': {'required': True, 'pattern': r'^[-\w\._,\(\)]+$'}, + 'outputs': {'readonly': True}, + 'provisioning_state': {'readonly': True}, + 'billing_details': {'readonly': True}, + 'publisher_tenant_id': {'readonly': True}, + 'authorizations': {'readonly': True}, + 'customer_support': {'readonly': True}, + 'support_urls': {'readonly': True}, + 'artifacts': {'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'}, + 'location': {'key': 'location', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + 'managed_by': {'key': 'managedBy', 'type': 'str'}, + 'sku': {'key': 'sku', 'type': 'Sku'}, + 'plan': {'key': 'plan', 'type': 'Plan'}, + 'kind': {'key': 'kind', 'type': 'str'}, + 'identity': {'key': 'identity', 'type': 'Identity'}, + 'managed_resource_group_id': {'key': 'properties.managedResourceGroupId', 'type': 'str'}, + 'application_definition_id': {'key': 'properties.applicationDefinitionId', 'type': 'str'}, + 'publisher_package_id': {'key': 'properties.publisherPackageId', 'type': 'str'}, + 'parameters': {'key': 'properties.parameters', 'type': 'object'}, + 'outputs': {'key': 'properties.outputs', 'type': 'object'}, + 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + 'billing_details': {'key': 'properties.billingDetails', 'type': 'ApplicationBillingDetailsDefinition'}, + 'jit_access_policy': {'key': 'properties.jitAccessPolicy', 'type': 'ApplicationJitAccessPolicy'}, + 'publisher_tenant_id': {'key': 'properties.publisherTenantId', 'type': 'str'}, + 'authorizations': {'key': 'properties.authorizations', 'type': '[ApplicationAuthorization]'}, + 'customer_support': {'key': 'properties.customerSupport', 'type': 'ApplicationPackageContact'}, + 'support_urls': {'key': 'properties.supportUrls', 'type': 'ApplicationPackageSupportUrls'}, + 'artifacts': {'key': 'properties.artifacts', 'type': '[ApplicationArtifact]'}, + 'created_by': {'key': 'properties.createdBy', 'type': 'ApplicationClientDetails'}, + 'updated_by': {'key': 'properties.updatedBy', 'type': 'ApplicationClientDetails'}, + } + + def __init__( + self, + *, + kind: str, + location: Optional[str] = None, + tags: Optional[Dict[str, str]] = None, + managed_by: Optional[str] = None, + sku: Optional["_models.Sku"] = None, + plan: Optional["_models.Plan"] = None, + identity: Optional["_models.Identity"] = None, + managed_resource_group_id: Optional[str] = None, + application_definition_id: Optional[str] = None, + publisher_package_id: Optional[str] = None, + parameters: Optional[Any] = None, + jit_access_policy: Optional["_models.ApplicationJitAccessPolicy"] = None, + **kwargs + ): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword managed_by: ID of the resource that manages this resource. + :paramtype managed_by: str + :keyword sku: The SKU of the resource. + :paramtype sku: ~azure.mgmt.managedapplication.v2018_03_01.models.Sku + :keyword plan: The plan information. + :paramtype plan: ~azure.mgmt.managedapplication.v2018_03_01.models.Plan + :keyword kind: Required. The kind of the managed application. Allowed values are MarketPlace + and ServiceCatalog. + :paramtype kind: str + :keyword identity: The identity of the resource. + :paramtype identity: ~azure.mgmt.managedapplication.v2018_03_01.models.Identity + :keyword managed_resource_group_id: The managed resource group Id. + :paramtype managed_resource_group_id: str + :keyword application_definition_id: The fully qualified path of managed application definition + Id. + :paramtype application_definition_id: str + :keyword publisher_package_id: The publisher package Id. + :paramtype publisher_package_id: str + :keyword parameters: Name and value pairs that define the managed application parameters. It + can be a JObject or a well formed JSON string. + :paramtype parameters: any + :keyword jit_access_policy: The managed application Jit access policy. + :paramtype jit_access_policy: + ~azure.mgmt.managedapplication.v2018_03_01.models.ApplicationJitAccessPolicy + """ + super(Application, self).__init__(location=location, tags=tags, managed_by=managed_by, sku=sku, **kwargs) + self.plan = plan + self.kind = kind + self.identity = identity + self.managed_resource_group_id = managed_resource_group_id + self.application_definition_id = application_definition_id + self.publisher_package_id = publisher_package_id + self.parameters = parameters + self.outputs = None + self.provisioning_state = None + self.billing_details = None + self.jit_access_policy = jit_access_policy + self.publisher_tenant_id = None + self.authorizations = None + self.customer_support = None + self.support_urls = None + self.artifacts = None + self.created_by = None + self.updated_by = None + + +class ApplicationArtifact(msrest.serialization.Model): + """Managed application artifact. + + All required parameters must be populated in order to send to Azure. + + :ivar name: Required. The managed application artifact name. Known values are: "NotSpecified", + "ViewDefinition", "Authorizations", "CustomRoleDefinition". + :vartype name: str or ~azure.mgmt.managedapplication.v2018_03_01.models.ApplicationArtifactName + :ivar uri: Required. The managed application artifact blob uri. + :vartype uri: str + :ivar type: Required. The managed application artifact type. Known values are: "NotSpecified", + "Template", "Custom". + :vartype type: str or ~azure.mgmt.managedapplication.v2018_03_01.models.ApplicationArtifactType + """ + + _validation = { + 'name': {'required': True}, + 'uri': {'required': True}, + 'type': {'required': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'uri': {'key': 'uri', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + } + + def __init__( + self, + *, + name: Union[str, "_models.ApplicationArtifactName"], + uri: str, + type: Union[str, "_models.ApplicationArtifactType"], + **kwargs + ): + """ + :keyword name: Required. The managed application artifact name. Known values are: + "NotSpecified", "ViewDefinition", "Authorizations", "CustomRoleDefinition". + :paramtype name: str or + ~azure.mgmt.managedapplication.v2018_03_01.models.ApplicationArtifactName + :keyword uri: Required. The managed application artifact blob uri. + :paramtype uri: str + :keyword type: Required. The managed application artifact type. Known values are: + "NotSpecified", "Template", "Custom". + :paramtype type: str or + ~azure.mgmt.managedapplication.v2018_03_01.models.ApplicationArtifactType + """ + super(ApplicationArtifact, self).__init__(**kwargs) + self.name = name + self.uri = uri + self.type = type + + +class ApplicationAuthorization(msrest.serialization.Model): + """The managed application provider authorization. + + All required parameters must be populated in order to send to Azure. + + :ivar principal_id: Required. The provider's principal identifier. This is the identity that + the provider will use to call ARM to manage the managed application resources. + :vartype principal_id: str + :ivar role_definition_id: Required. The provider's role definition identifier. This role will + define all the permissions that the provider must have on the managed application's container + resource group. This role definition cannot have permission to delete the resource group. + :vartype role_definition_id: str + """ + + _validation = { + 'principal_id': {'required': True}, + 'role_definition_id': {'required': True}, + } + + _attribute_map = { + 'principal_id': {'key': 'principalId', 'type': 'str'}, + 'role_definition_id': {'key': 'roleDefinitionId', 'type': 'str'}, + } + + def __init__( + self, + *, + principal_id: str, + role_definition_id: str, + **kwargs + ): + """ + :keyword principal_id: Required. The provider's principal identifier. This is the identity that + the provider will use to call ARM to manage the managed application resources. + :paramtype principal_id: str + :keyword role_definition_id: Required. The provider's role definition identifier. This role + will define all the permissions that the provider must have on the managed application's + container resource group. This role definition cannot have permission to delete the resource + group. + :paramtype role_definition_id: str + """ + super(ApplicationAuthorization, self).__init__(**kwargs) + self.principal_id = principal_id + self.role_definition_id = role_definition_id + + +class ApplicationBillingDetailsDefinition(msrest.serialization.Model): + """Managed application billing details definition. + + :ivar resource_usage_id: The managed application resource usage Id. + :vartype resource_usage_id: str + """ + + _attribute_map = { + 'resource_usage_id': {'key': 'resourceUsageId', 'type': 'str'}, + } + + def __init__( + self, + *, + resource_usage_id: Optional[str] = None, + **kwargs + ): + """ + :keyword resource_usage_id: The managed application resource usage Id. + :paramtype resource_usage_id: str + """ + super(ApplicationBillingDetailsDefinition, self).__init__(**kwargs) + self.resource_usage_id = resource_usage_id + + +class ApplicationClientDetails(msrest.serialization.Model): + """The application client details to track the entity creating/updating the managed app resource. + + :ivar oid: The client Oid. + :vartype oid: str + :ivar puid: The client Puid. + :vartype puid: str + :ivar application_id: The client application Id. + :vartype application_id: str + """ + + _attribute_map = { + 'oid': {'key': 'oid', 'type': 'str'}, + 'puid': {'key': 'puid', 'type': 'str'}, + 'application_id': {'key': 'applicationId', 'type': 'str'}, + } + + def __init__( + self, + *, + oid: Optional[str] = None, + puid: Optional[str] = None, + application_id: Optional[str] = None, + **kwargs + ): + """ + :keyword oid: The client Oid. + :paramtype oid: str + :keyword puid: The client Puid. + :paramtype puid: str + :keyword application_id: The client application Id. + :paramtype application_id: str + """ + super(ApplicationClientDetails, self).__init__(**kwargs) + self.oid = oid + self.puid = puid + self.application_id = application_id + + +class ApplicationDefinition(GenericResource): + """Information about managed application definition. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar id: Resource ID. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar location: Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar managed_by: ID of the resource that manages this resource. + :vartype managed_by: str + :ivar sku: The SKU of the resource. + :vartype sku: ~azure.mgmt.managedapplication.v2018_03_01.models.Sku + :ivar lock_level: Required. The managed application lock level. Known values are: + "CanNotDelete", "ReadOnly", "None". + :vartype lock_level: str or + ~azure.mgmt.managedapplication.v2018_03_01.models.ApplicationLockLevel + :ivar display_name: The managed application definition display name. + :vartype display_name: str + :ivar is_enabled: A value indicating whether the package is enabled or not. + :vartype is_enabled: bool + :ivar authorizations: The managed application provider authorizations. + :vartype authorizations: + list[~azure.mgmt.managedapplication.v2018_03_01.models.ApplicationAuthorization] + :ivar artifacts: The collection of managed application artifacts. The portal will use the files + specified as artifacts to construct the user experience of creating a managed application from + a managed application definition. + :vartype artifacts: + list[~azure.mgmt.managedapplication.v2018_03_01.models.ApplicationDefinitionArtifact] + :ivar description: The managed application definition description. + :vartype description: str + :ivar package_file_uri: The managed application definition package file Uri. Use this element. + :vartype package_file_uri: str + :ivar main_template: The inline main template json which has resources to be provisioned. It + can be a JObject or well-formed JSON string. + :vartype main_template: any + :ivar create_ui_definition: The createUiDefinition json for the backing template with + Microsoft.Solutions/applications resource. It can be a JObject or well-formed JSON string. + :vartype create_ui_definition: any + :ivar policies: The managed application provider policies. + :vartype policies: list[~azure.mgmt.managedapplication.v2018_03_01.models.ApplicationPolicy] + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'lock_level': {'required': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'location': {'key': 'location', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + 'managed_by': {'key': 'managedBy', 'type': 'str'}, + 'sku': {'key': 'sku', 'type': 'Sku'}, + 'lock_level': {'key': 'properties.lockLevel', 'type': 'str'}, + 'display_name': {'key': 'properties.displayName', 'type': 'str'}, + 'is_enabled': {'key': 'properties.isEnabled', 'type': 'bool'}, + 'authorizations': {'key': 'properties.authorizations', 'type': '[ApplicationAuthorization]'}, + 'artifacts': {'key': 'properties.artifacts', 'type': '[ApplicationDefinitionArtifact]'}, + 'description': {'key': 'properties.description', 'type': 'str'}, + 'package_file_uri': {'key': 'properties.packageFileUri', 'type': 'str'}, + 'main_template': {'key': 'properties.mainTemplate', 'type': 'object'}, + 'create_ui_definition': {'key': 'properties.createUiDefinition', 'type': 'object'}, + 'policies': {'key': 'properties.policies', 'type': '[ApplicationPolicy]'}, + } + + def __init__( + self, + *, + lock_level: Union[str, "_models.ApplicationLockLevel"], + location: Optional[str] = None, + tags: Optional[Dict[str, str]] = None, + managed_by: Optional[str] = None, + sku: Optional["_models.Sku"] = None, + display_name: Optional[str] = None, + is_enabled: Optional[bool] = None, + authorizations: Optional[List["_models.ApplicationAuthorization"]] = None, + artifacts: Optional[List["_models.ApplicationDefinitionArtifact"]] = None, + description: Optional[str] = None, + package_file_uri: Optional[str] = None, + main_template: Optional[Any] = None, + create_ui_definition: Optional[Any] = None, + policies: Optional[List["_models.ApplicationPolicy"]] = None, + **kwargs + ): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword managed_by: ID of the resource that manages this resource. + :paramtype managed_by: str + :keyword sku: The SKU of the resource. + :paramtype sku: ~azure.mgmt.managedapplication.v2018_03_01.models.Sku + :keyword lock_level: Required. The managed application lock level. Known values are: + "CanNotDelete", "ReadOnly", "None". + :paramtype lock_level: str or + ~azure.mgmt.managedapplication.v2018_03_01.models.ApplicationLockLevel + :keyword display_name: The managed application definition display name. + :paramtype display_name: str + :keyword is_enabled: A value indicating whether the package is enabled or not. + :paramtype is_enabled: bool + :keyword authorizations: The managed application provider authorizations. + :paramtype authorizations: + list[~azure.mgmt.managedapplication.v2018_03_01.models.ApplicationAuthorization] + :keyword artifacts: The collection of managed application artifacts. The portal will use the + files specified as artifacts to construct the user experience of creating a managed application + from a managed application definition. + :paramtype artifacts: + list[~azure.mgmt.managedapplication.v2018_03_01.models.ApplicationDefinitionArtifact] + :keyword description: The managed application definition description. + :paramtype description: str + :keyword package_file_uri: The managed application definition package file Uri. Use this + element. + :paramtype package_file_uri: str + :keyword main_template: The inline main template json which has resources to be provisioned. It + can be a JObject or well-formed JSON string. + :paramtype main_template: any + :keyword create_ui_definition: The createUiDefinition json for the backing template with + Microsoft.Solutions/applications resource. It can be a JObject or well-formed JSON string. + :paramtype create_ui_definition: any + :keyword policies: The managed application provider policies. + :paramtype policies: list[~azure.mgmt.managedapplication.v2018_03_01.models.ApplicationPolicy] + """ + super(ApplicationDefinition, self).__init__(location=location, tags=tags, managed_by=managed_by, sku=sku, **kwargs) + self.lock_level = lock_level + self.display_name = display_name + self.is_enabled = is_enabled + self.authorizations = authorizations + self.artifacts = artifacts + self.description = description + self.package_file_uri = package_file_uri + self.main_template = main_template + self.create_ui_definition = create_ui_definition + self.policies = policies + + +class ApplicationDefinitionArtifact(msrest.serialization.Model): + """Application definition artifact. + + All required parameters must be populated in order to send to Azure. + + :ivar name: Required. The managed application definition artifact name. Known values are: + "NotSpecified", "ApplicationResourceTemplate", "CreateUiDefinition", "MainTemplateParameters". + :vartype name: str or + ~azure.mgmt.managedapplication.v2018_03_01.models.ApplicationDefinitionArtifactName + :ivar uri: Required. The managed application definition artifact blob uri. + :vartype uri: str + :ivar type: Required. The managed application definition artifact type. Known values are: + "NotSpecified", "Template", "Custom". + :vartype type: str or ~azure.mgmt.managedapplication.v2018_03_01.models.ApplicationArtifactType + """ + + _validation = { + 'name': {'required': True}, + 'uri': {'required': True}, + 'type': {'required': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'uri': {'key': 'uri', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + } + + def __init__( + self, + *, + name: Union[str, "_models.ApplicationDefinitionArtifactName"], + uri: str, + type: Union[str, "_models.ApplicationArtifactType"], + **kwargs + ): + """ + :keyword name: Required. The managed application definition artifact name. Known values are: + "NotSpecified", "ApplicationResourceTemplate", "CreateUiDefinition", "MainTemplateParameters". + :paramtype name: str or + ~azure.mgmt.managedapplication.v2018_03_01.models.ApplicationDefinitionArtifactName + :keyword uri: Required. The managed application definition artifact blob uri. + :paramtype uri: str + :keyword type: Required. The managed application definition artifact type. Known values are: + "NotSpecified", "Template", "Custom". + :paramtype type: str or + ~azure.mgmt.managedapplication.v2018_03_01.models.ApplicationArtifactType + """ + super(ApplicationDefinitionArtifact, self).__init__(**kwargs) + self.name = name + self.uri = uri + self.type = type + + +class ApplicationDefinitionListResult(msrest.serialization.Model): + """List of managed application definitions. + + :ivar value: The array of managed application definitions. + :vartype value: list[~azure.mgmt.managedapplication.v2018_03_01.models.ApplicationDefinition] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[ApplicationDefinition]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["_models.ApplicationDefinition"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + """ + :keyword value: The array of managed application definitions. + :paramtype value: list[~azure.mgmt.managedapplication.v2018_03_01.models.ApplicationDefinition] + :keyword next_link: The URL to use for getting the next set of results. + :paramtype next_link: str + """ + super(ApplicationDefinitionListResult, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class ApplicationDefinitionPatchable(msrest.serialization.Model): + """Information about an application definition request. + + :ivar tags: A set of tags. Application definition tags. + :vartype tags: dict[str, str] + """ + + _attribute_map = { + 'tags': {'key': 'tags', 'type': '{str}'}, + } + + def __init__( + self, + *, + tags: Optional[Dict[str, str]] = None, + **kwargs + ): + """ + :keyword tags: A set of tags. Application definition tags. + :paramtype tags: dict[str, str] + """ + super(ApplicationDefinitionPatchable, self).__init__(**kwargs) + self.tags = tags + + +class ApplicationJitAccessPolicy(msrest.serialization.Model): + """Managed application Jit access policy. + + All required parameters must be populated in order to send to Azure. + + :ivar jit_access_enabled: Required. Whether the JIT access is enabled. + :vartype jit_access_enabled: bool + :ivar jit_approval_mode: JIT approval mode. Known values are: "NotSpecified", "AutoApprove", + "ManualApprove". + :vartype jit_approval_mode: str or + ~azure.mgmt.managedapplication.v2018_03_01.models.JitApprovalMode + :ivar jit_approvers: The JIT approvers. + :vartype jit_approvers: + list[~azure.mgmt.managedapplication.v2018_03_01.models.JitApproverDefinition] + :ivar maximum_jit_access_duration: The maximum duration JIT access is granted. This is an + ISO8601 time period value. + :vartype maximum_jit_access_duration: str + """ + + _validation = { + 'jit_access_enabled': {'required': True}, + } + + _attribute_map = { + 'jit_access_enabled': {'key': 'jitAccessEnabled', 'type': 'bool'}, + 'jit_approval_mode': {'key': 'jitApprovalMode', 'type': 'str'}, + 'jit_approvers': {'key': 'jitApprovers', 'type': '[JitApproverDefinition]'}, + 'maximum_jit_access_duration': {'key': 'maximumJitAccessDuration', 'type': 'str'}, + } + + def __init__( + self, + *, + jit_access_enabled: bool, + jit_approval_mode: Optional[Union[str, "_models.JitApprovalMode"]] = None, + jit_approvers: Optional[List["_models.JitApproverDefinition"]] = None, + maximum_jit_access_duration: Optional[str] = None, + **kwargs + ): + """ + :keyword jit_access_enabled: Required. Whether the JIT access is enabled. + :paramtype jit_access_enabled: bool + :keyword jit_approval_mode: JIT approval mode. Known values are: "NotSpecified", "AutoApprove", + "ManualApprove". + :paramtype jit_approval_mode: str or + ~azure.mgmt.managedapplication.v2018_03_01.models.JitApprovalMode + :keyword jit_approvers: The JIT approvers. + :paramtype jit_approvers: + list[~azure.mgmt.managedapplication.v2018_03_01.models.JitApproverDefinition] + :keyword maximum_jit_access_duration: The maximum duration JIT access is granted. This is an + ISO8601 time period value. + :paramtype maximum_jit_access_duration: str + """ + super(ApplicationJitAccessPolicy, self).__init__(**kwargs) + self.jit_access_enabled = jit_access_enabled + self.jit_approval_mode = jit_approval_mode + self.jit_approvers = jit_approvers + self.maximum_jit_access_duration = maximum_jit_access_duration + + +class ApplicationListResult(msrest.serialization.Model): + """List of managed applications. + + :ivar value: The array of managed applications. + :vartype value: list[~azure.mgmt.managedapplication.v2018_03_01.models.Application] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Application]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["_models.Application"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + """ + :keyword value: The array of managed applications. + :paramtype value: list[~azure.mgmt.managedapplication.v2018_03_01.models.Application] + :keyword next_link: The URL to use for getting the next set of results. + :paramtype next_link: str + """ + super(ApplicationListResult, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class ApplicationPackageContact(msrest.serialization.Model): + """The application package contact information. + + All required parameters must be populated in order to send to Azure. + + :ivar contact_name: The contact name. + :vartype contact_name: str + :ivar email: Required. The contact email. + :vartype email: str + :ivar phone: Required. The contact phone number. + :vartype phone: str + """ + + _validation = { + 'email': {'required': True}, + 'phone': {'required': True}, + } + + _attribute_map = { + 'contact_name': {'key': 'contactName', 'type': 'str'}, + 'email': {'key': 'email', 'type': 'str'}, + 'phone': {'key': 'phone', 'type': 'str'}, + } + + def __init__( + self, + *, + email: str, + phone: str, + contact_name: Optional[str] = None, + **kwargs + ): + """ + :keyword contact_name: The contact name. + :paramtype contact_name: str + :keyword email: Required. The contact email. + :paramtype email: str + :keyword phone: Required. The contact phone number. + :paramtype phone: str + """ + super(ApplicationPackageContact, self).__init__(**kwargs) + self.contact_name = contact_name + self.email = email + self.phone = phone + + +class ApplicationPackageSupportUrls(msrest.serialization.Model): + """The appliance package support URLs. + + :ivar public_azure: The public azure support URL. + :vartype public_azure: str + :ivar government_cloud: The government cloud support URL. + :vartype government_cloud: str + """ + + _attribute_map = { + 'public_azure': {'key': 'publicAzure', 'type': 'str'}, + 'government_cloud': {'key': 'governmentCloud', 'type': 'str'}, + } + + def __init__( + self, + *, + public_azure: Optional[str] = None, + government_cloud: Optional[str] = None, + **kwargs + ): + """ + :keyword public_azure: The public azure support URL. + :paramtype public_azure: str + :keyword government_cloud: The government cloud support URL. + :paramtype government_cloud: str + """ + super(ApplicationPackageSupportUrls, self).__init__(**kwargs) + self.public_azure = public_azure + self.government_cloud = government_cloud + + +class ApplicationPatchable(GenericResource): + """Information about managed application. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Resource ID. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar location: Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar managed_by: ID of the resource that manages this resource. + :vartype managed_by: str + :ivar sku: The SKU of the resource. + :vartype sku: ~azure.mgmt.managedapplication.v2018_03_01.models.Sku + :ivar plan: The plan information. + :vartype plan: ~azure.mgmt.managedapplication.v2018_03_01.models.PlanPatchable + :ivar kind: The kind of the managed application. Allowed values are MarketPlace and + ServiceCatalog. + :vartype kind: str + :ivar identity: The identity of the resource. + :vartype identity: ~azure.mgmt.managedapplication.v2018_03_01.models.Identity + :ivar managed_resource_group_id: The managed resource group Id. + :vartype managed_resource_group_id: str + :ivar application_definition_id: The fully qualified path of managed application definition Id. + :vartype application_definition_id: str + :ivar publisher_package_id: The publisher package Id. + :vartype publisher_package_id: str + :ivar parameters: Name and value pairs that define the managed application parameters. It can + be a JObject or a well formed JSON string. + :vartype parameters: any + :ivar outputs: Name and value pairs that define the managed application outputs. + :vartype outputs: any + :ivar provisioning_state: The managed application provisioning state. Known values are: + "NotSpecified", "Accepted", "Running", "Ready", "Creating", "Created", "Deleting", "Deleted", + "Canceled", "Failed", "Succeeded", "Updating". + :vartype provisioning_state: str or + ~azure.mgmt.managedapplication.v2018_03_01.models.ProvisioningState + :ivar billing_details: The managed application billing details. + :vartype billing_details: + ~azure.mgmt.managedapplication.v2018_03_01.models.ApplicationBillingDetailsDefinition + :ivar jit_access_policy: The managed application Jit access policy. + :vartype jit_access_policy: + ~azure.mgmt.managedapplication.v2018_03_01.models.ApplicationJitAccessPolicy + :ivar publisher_tenant_id: The publisher tenant Id. + :vartype publisher_tenant_id: str + :ivar authorizations: The read-only authorizations property that is retrieved from the + application package. + :vartype authorizations: + list[~azure.mgmt.managedapplication.v2018_03_01.models.ApplicationAuthorization] + :ivar customer_support: The read-only customer support property that is retrieved from the + application package. + :vartype customer_support: + ~azure.mgmt.managedapplication.v2018_03_01.models.ApplicationPackageContact + :ivar support_urls: The read-only support URLs property that is retrieved from the application + package. + :vartype support_urls: + ~azure.mgmt.managedapplication.v2018_03_01.models.ApplicationPackageSupportUrls + :ivar artifacts: The collection of managed application artifacts. + :vartype artifacts: list[~azure.mgmt.managedapplication.v2018_03_01.models.ApplicationArtifact] + :ivar created_by: The client entity that created the JIT request. + :vartype created_by: ~azure.mgmt.managedapplication.v2018_03_01.models.ApplicationClientDetails + :ivar updated_by: The client entity that last updated the JIT request. + :vartype updated_by: ~azure.mgmt.managedapplication.v2018_03_01.models.ApplicationClientDetails + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'kind': {'pattern': r'^[-\w\._,\(\)]+$'}, + 'outputs': {'readonly': True}, + 'provisioning_state': {'readonly': True}, + 'billing_details': {'readonly': True}, + 'publisher_tenant_id': {'readonly': True}, + 'authorizations': {'readonly': True}, + 'customer_support': {'readonly': True}, + 'support_urls': {'readonly': True}, + 'artifacts': {'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'}, + 'location': {'key': 'location', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + 'managed_by': {'key': 'managedBy', 'type': 'str'}, + 'sku': {'key': 'sku', 'type': 'Sku'}, + 'plan': {'key': 'plan', 'type': 'PlanPatchable'}, + 'kind': {'key': 'kind', 'type': 'str'}, + 'identity': {'key': 'identity', 'type': 'Identity'}, + 'managed_resource_group_id': {'key': 'properties.managedResourceGroupId', 'type': 'str'}, + 'application_definition_id': {'key': 'properties.applicationDefinitionId', 'type': 'str'}, + 'publisher_package_id': {'key': 'properties.publisherPackageId', 'type': 'str'}, + 'parameters': {'key': 'properties.parameters', 'type': 'object'}, + 'outputs': {'key': 'properties.outputs', 'type': 'object'}, + 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + 'billing_details': {'key': 'properties.billingDetails', 'type': 'ApplicationBillingDetailsDefinition'}, + 'jit_access_policy': {'key': 'properties.jitAccessPolicy', 'type': 'ApplicationJitAccessPolicy'}, + 'publisher_tenant_id': {'key': 'properties.publisherTenantId', 'type': 'str'}, + 'authorizations': {'key': 'properties.authorizations', 'type': '[ApplicationAuthorization]'}, + 'customer_support': {'key': 'properties.customerSupport', 'type': 'ApplicationPackageContact'}, + 'support_urls': {'key': 'properties.supportUrls', 'type': 'ApplicationPackageSupportUrls'}, + 'artifacts': {'key': 'properties.artifacts', 'type': '[ApplicationArtifact]'}, + 'created_by': {'key': 'properties.createdBy', 'type': 'ApplicationClientDetails'}, + 'updated_by': {'key': 'properties.updatedBy', 'type': 'ApplicationClientDetails'}, + } + + def __init__( + self, + *, + location: Optional[str] = None, + tags: Optional[Dict[str, str]] = None, + managed_by: Optional[str] = None, + sku: Optional["_models.Sku"] = None, + plan: Optional["_models.PlanPatchable"] = None, + kind: Optional[str] = None, + identity: Optional["_models.Identity"] = None, + managed_resource_group_id: Optional[str] = None, + application_definition_id: Optional[str] = None, + publisher_package_id: Optional[str] = None, + parameters: Optional[Any] = None, + jit_access_policy: Optional["_models.ApplicationJitAccessPolicy"] = None, + **kwargs + ): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword managed_by: ID of the resource that manages this resource. + :paramtype managed_by: str + :keyword sku: The SKU of the resource. + :paramtype sku: ~azure.mgmt.managedapplication.v2018_03_01.models.Sku + :keyword plan: The plan information. + :paramtype plan: ~azure.mgmt.managedapplication.v2018_03_01.models.PlanPatchable + :keyword kind: The kind of the managed application. Allowed values are MarketPlace and + ServiceCatalog. + :paramtype kind: str + :keyword identity: The identity of the resource. + :paramtype identity: ~azure.mgmt.managedapplication.v2018_03_01.models.Identity + :keyword managed_resource_group_id: The managed resource group Id. + :paramtype managed_resource_group_id: str + :keyword application_definition_id: The fully qualified path of managed application definition + Id. + :paramtype application_definition_id: str + :keyword publisher_package_id: The publisher package Id. + :paramtype publisher_package_id: str + :keyword parameters: Name and value pairs that define the managed application parameters. It + can be a JObject or a well formed JSON string. + :paramtype parameters: any + :keyword jit_access_policy: The managed application Jit access policy. + :paramtype jit_access_policy: + ~azure.mgmt.managedapplication.v2018_03_01.models.ApplicationJitAccessPolicy + """ + super(ApplicationPatchable, self).__init__(location=location, tags=tags, managed_by=managed_by, sku=sku, **kwargs) + self.plan = plan + self.kind = kind + self.identity = identity + self.managed_resource_group_id = managed_resource_group_id + self.application_definition_id = application_definition_id + self.publisher_package_id = publisher_package_id + self.parameters = parameters + self.outputs = None + self.provisioning_state = None + self.billing_details = None + self.jit_access_policy = jit_access_policy + self.publisher_tenant_id = None + self.authorizations = None + self.customer_support = None + self.support_urls = None + self.artifacts = None + self.created_by = None + self.updated_by = None + + +class ApplicationPolicy(msrest.serialization.Model): + """Managed application policy. + + :ivar name: The policy name. + :vartype name: str + :ivar policy_definition_id: The policy definition Id. + :vartype policy_definition_id: str + :ivar parameters: The policy parameters. + :vartype parameters: str + """ + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'policy_definition_id': {'key': 'policyDefinitionId', 'type': 'str'}, + 'parameters': {'key': 'parameters', 'type': 'str'}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + policy_definition_id: Optional[str] = None, + parameters: Optional[str] = None, + **kwargs + ): + """ + :keyword name: The policy name. + :paramtype name: str + :keyword policy_definition_id: The policy definition Id. + :paramtype policy_definition_id: str + :keyword parameters: The policy parameters. + :paramtype parameters: str + """ + super(ApplicationPolicy, self).__init__(**kwargs) + self.name = name + self.policy_definition_id = policy_definition_id + self.parameters = parameters + + +class ApplicationPropertiesPatchable(msrest.serialization.Model): + """The managed application properties. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar managed_resource_group_id: The managed resource group Id. + :vartype managed_resource_group_id: str + :ivar application_definition_id: The fully qualified path of managed application definition Id. + :vartype application_definition_id: str + :ivar parameters: Name and value pairs that define the managed application parameters. It can + be a JObject or a well formed JSON string. + :vartype parameters: any + :ivar outputs: Name and value pairs that define the managed application outputs. + :vartype outputs: any + :ivar provisioning_state: The managed application provisioning state. Known values are: + "NotSpecified", "Accepted", "Running", "Ready", "Creating", "Created", "Deleting", "Deleted", + "Canceled", "Failed", "Succeeded", "Updating". + :vartype provisioning_state: str or + ~azure.mgmt.managedapplication.v2018_03_01.models.ProvisioningState + """ + + _validation = { + 'outputs': {'readonly': True}, + 'provisioning_state': {'readonly': True}, + } + + _attribute_map = { + 'managed_resource_group_id': {'key': 'managedResourceGroupId', 'type': 'str'}, + 'application_definition_id': {'key': 'applicationDefinitionId', 'type': 'str'}, + 'parameters': {'key': 'parameters', 'type': 'object'}, + 'outputs': {'key': 'outputs', 'type': 'object'}, + 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, + } + + def __init__( + self, + *, + managed_resource_group_id: Optional[str] = None, + application_definition_id: Optional[str] = None, + parameters: Optional[Any] = None, + **kwargs + ): + """ + :keyword managed_resource_group_id: The managed resource group Id. + :paramtype managed_resource_group_id: str + :keyword application_definition_id: The fully qualified path of managed application definition + Id. + :paramtype application_definition_id: str + :keyword parameters: Name and value pairs that define the managed application parameters. It + can be a JObject or a well formed JSON string. + :paramtype parameters: any + """ + super(ApplicationPropertiesPatchable, self).__init__(**kwargs) + self.managed_resource_group_id = managed_resource_group_id + self.application_definition_id = application_definition_id + self.parameters = parameters + self.outputs = None + self.provisioning_state = None + + +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.managedapplication.v2018_03_01.models.ErrorDetail] + :ivar additional_info: The error additional info. + :vartype additional_info: + list[~azure.mgmt.managedapplication.v2018_03_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.). + + :ivar error: The error object. + :vartype error: ~azure.mgmt.managedapplication.v2018_03_01.models.ErrorDetail + """ + + _attribute_map = { + 'error': {'key': 'error', 'type': 'ErrorDetail'}, + } + + def __init__( + self, + *, + error: Optional["_models.ErrorDetail"] = None, + **kwargs + ): + """ + :keyword error: The error object. + :paramtype error: ~azure.mgmt.managedapplication.v2018_03_01.models.ErrorDetail + """ + super(ErrorResponse, self).__init__(**kwargs) + self.error = error + + +class Identity(msrest.serialization.Model): + """Identity for the resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar principal_id: The principal ID of resource identity. + :vartype principal_id: str + :ivar tenant_id: The tenant ID of resource. + :vartype tenant_id: str + :ivar type: The identity type. Known values are: "SystemAssigned", "UserAssigned", + "SystemAssigned, UserAssigned", "None". + :vartype type: str or ~azure.mgmt.managedapplication.v2018_03_01.models.ResourceIdentityType + :ivar user_assigned_identities: The list of user identities associated with the resource. The + user identity dictionary key references will be resource ids in the form: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'. + :vartype user_assigned_identities: dict[str, + ~azure.mgmt.managedapplication.v2018_03_01.models.UserAssignedResourceIdentity] + """ + + _validation = { + 'principal_id': {'readonly': True}, + 'tenant_id': {'readonly': True}, + } + + _attribute_map = { + 'principal_id': {'key': 'principalId', 'type': 'str'}, + 'tenant_id': {'key': 'tenantId', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'user_assigned_identities': {'key': 'userAssignedIdentities', 'type': '{UserAssignedResourceIdentity}'}, + } + + def __init__( + self, + *, + type: Optional[Union[str, "_models.ResourceIdentityType"]] = None, + user_assigned_identities: Optional[Dict[str, "_models.UserAssignedResourceIdentity"]] = None, + **kwargs + ): + """ + :keyword type: The identity type. Known values are: "SystemAssigned", "UserAssigned", + "SystemAssigned, UserAssigned", "None". + :paramtype type: str or ~azure.mgmt.managedapplication.v2018_03_01.models.ResourceIdentityType + :keyword user_assigned_identities: The list of user identities associated with the resource. + The user identity dictionary key references will be resource ids in the form: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'. + :paramtype user_assigned_identities: dict[str, + ~azure.mgmt.managedapplication.v2018_03_01.models.UserAssignedResourceIdentity] + """ + super(Identity, self).__init__(**kwargs) + self.principal_id = None + self.tenant_id = None + self.type = type + self.user_assigned_identities = user_assigned_identities + + +class JitApproverDefinition(msrest.serialization.Model): + """JIT approver definition. + + All required parameters must be populated in order to send to Azure. + + :ivar id: Required. The approver service principal Id. + :vartype id: str + :ivar type: The approver type. Known values are: "user", "group". + :vartype type: str or ~azure.mgmt.managedapplication.v2018_03_01.models.JitApproverType + :ivar display_name: The approver display name. + :vartype display_name: str + """ + + _validation = { + 'id': {'required': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'display_name': {'key': 'displayName', 'type': 'str'}, + } + + def __init__( + self, + *, + id: str, + type: Optional[Union[str, "_models.JitApproverType"]] = None, + display_name: Optional[str] = None, + **kwargs + ): + """ + :keyword id: Required. The approver service principal Id. + :paramtype id: str + :keyword type: The approver type. Known values are: "user", "group". + :paramtype type: str or ~azure.mgmt.managedapplication.v2018_03_01.models.JitApproverType + :keyword display_name: The approver display name. + :paramtype display_name: str + """ + super(JitApproverDefinition, self).__init__(**kwargs) + self.id = id + self.type = type + self.display_name = display_name + + +class JitAuthorizationPolicies(msrest.serialization.Model): + """The JIT authorization policies. + + All required parameters must be populated in order to send to Azure. + + :ivar principal_id: Required. The the principal id that will be granted JIT access. + :vartype principal_id: str + :ivar role_definition_id: Required. The role definition id that will be granted to the + Principal. + :vartype role_definition_id: str + """ + + _validation = { + 'principal_id': {'required': True}, + 'role_definition_id': {'required': True}, + } + + _attribute_map = { + 'principal_id': {'key': 'principalId', 'type': 'str'}, + 'role_definition_id': {'key': 'roleDefinitionId', 'type': 'str'}, + } + + def __init__( + self, + *, + principal_id: str, + role_definition_id: str, + **kwargs + ): + """ + :keyword principal_id: Required. The the principal id that will be granted JIT access. + :paramtype principal_id: str + :keyword role_definition_id: Required. The role definition id that will be granted to the + Principal. + :paramtype role_definition_id: str + """ + super(JitAuthorizationPolicies, self).__init__(**kwargs) + self.principal_id = principal_id + self.role_definition_id = role_definition_id + + +class JitRequestDefinition(Resource): + """Information about JIT request definition. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Resource ID. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar location: Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar application_resource_id: The parent application id. + :vartype application_resource_id: str + :ivar publisher_tenant_id: The publisher tenant id. + :vartype publisher_tenant_id: str + :ivar jit_authorization_policies: The JIT authorization policies. + :vartype jit_authorization_policies: + list[~azure.mgmt.managedapplication.v2018_03_01.models.JitAuthorizationPolicies] + :ivar jit_scheduling_policy: The JIT request properties. + :vartype jit_scheduling_policy: + ~azure.mgmt.managedapplication.v2018_03_01.models.JitSchedulingPolicy + :ivar provisioning_state: The JIT request provisioning state. Known values are: "NotSpecified", + "Accepted", "Running", "Ready", "Creating", "Created", "Deleting", "Deleted", "Canceled", + "Failed", "Succeeded", "Updating". + :vartype provisioning_state: str or + ~azure.mgmt.managedapplication.v2018_03_01.models.ProvisioningState + :ivar jit_request_state: The JIT request state. Known values are: "NotSpecified", "Pending", + "Approved", "Denied", "Failed", "Canceled", "Expired", "Timeout". + :vartype jit_request_state: str or + ~azure.mgmt.managedapplication.v2018_03_01.models.JitRequestState + :ivar created_by: The client entity that created the JIT request. + :vartype created_by: ~azure.mgmt.managedapplication.v2018_03_01.models.ApplicationClientDetails + :ivar updated_by: The client entity that last updated the JIT request. + :vartype updated_by: ~azure.mgmt.managedapplication.v2018_03_01.models.ApplicationClientDetails + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'publisher_tenant_id': {'readonly': True}, + 'provisioning_state': {'readonly': True}, + 'jit_request_state': {'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'}, + 'location': {'key': 'location', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + 'application_resource_id': {'key': 'properties.applicationResourceId', 'type': 'str'}, + 'publisher_tenant_id': {'key': 'properties.publisherTenantId', 'type': 'str'}, + 'jit_authorization_policies': {'key': 'properties.jitAuthorizationPolicies', 'type': '[JitAuthorizationPolicies]'}, + 'jit_scheduling_policy': {'key': 'properties.jitSchedulingPolicy', 'type': 'JitSchedulingPolicy'}, + 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + 'jit_request_state': {'key': 'properties.jitRequestState', 'type': 'str'}, + 'created_by': {'key': 'properties.createdBy', 'type': 'ApplicationClientDetails'}, + 'updated_by': {'key': 'properties.updatedBy', 'type': 'ApplicationClientDetails'}, + } + + def __init__( + self, + *, + location: Optional[str] = None, + tags: Optional[Dict[str, str]] = None, + application_resource_id: Optional[str] = None, + jit_authorization_policies: Optional[List["_models.JitAuthorizationPolicies"]] = None, + jit_scheduling_policy: Optional["_models.JitSchedulingPolicy"] = None, + **kwargs + ): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword application_resource_id: The parent application id. + :paramtype application_resource_id: str + :keyword jit_authorization_policies: The JIT authorization policies. + :paramtype jit_authorization_policies: + list[~azure.mgmt.managedapplication.v2018_03_01.models.JitAuthorizationPolicies] + :keyword jit_scheduling_policy: The JIT request properties. + :paramtype jit_scheduling_policy: + ~azure.mgmt.managedapplication.v2018_03_01.models.JitSchedulingPolicy + """ + super(JitRequestDefinition, self).__init__(location=location, tags=tags, **kwargs) + self.application_resource_id = application_resource_id + self.publisher_tenant_id = None + self.jit_authorization_policies = jit_authorization_policies + self.jit_scheduling_policy = jit_scheduling_policy + self.provisioning_state = None + self.jit_request_state = None + self.created_by = None + self.updated_by = None + + +class JitRequestDefinitionListResult(msrest.serialization.Model): + """List of JIT requests. + + :ivar value: The array of Jit request definition. + :vartype value: list[~azure.mgmt.managedapplication.v2018_03_01.models.JitRequestDefinition] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[JitRequestDefinition]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["_models.JitRequestDefinition"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + """ + :keyword value: The array of Jit request definition. + :paramtype value: list[~azure.mgmt.managedapplication.v2018_03_01.models.JitRequestDefinition] + :keyword next_link: The URL to use for getting the next set of results. + :paramtype next_link: str + """ + super(JitRequestDefinitionListResult, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class JitRequestMetadata(msrest.serialization.Model): + """The JIT request metadata. + + :ivar origin_request_id: The origin request id. + :vartype origin_request_id: str + :ivar requestor_id: The requestor id. + :vartype requestor_id: str + :ivar tenant_display_name: The publisher's tenant name. + :vartype tenant_display_name: str + :ivar subject_display_name: The subject display name. + :vartype subject_display_name: str + """ + + _attribute_map = { + 'origin_request_id': {'key': 'originRequestId', 'type': 'str'}, + 'requestor_id': {'key': 'requestorId', 'type': 'str'}, + 'tenant_display_name': {'key': 'tenantDisplayName', 'type': 'str'}, + 'subject_display_name': {'key': 'subjectDisplayName', 'type': 'str'}, + } + + def __init__( + self, + *, + origin_request_id: Optional[str] = None, + requestor_id: Optional[str] = None, + tenant_display_name: Optional[str] = None, + subject_display_name: Optional[str] = None, + **kwargs + ): + """ + :keyword origin_request_id: The origin request id. + :paramtype origin_request_id: str + :keyword requestor_id: The requestor id. + :paramtype requestor_id: str + :keyword tenant_display_name: The publisher's tenant name. + :paramtype tenant_display_name: str + :keyword subject_display_name: The subject display name. + :paramtype subject_display_name: str + """ + super(JitRequestMetadata, self).__init__(**kwargs) + self.origin_request_id = origin_request_id + self.requestor_id = requestor_id + self.tenant_display_name = tenant_display_name + self.subject_display_name = subject_display_name + + +class JitRequestPatchable(msrest.serialization.Model): + """Information about JIT request. + + :ivar tags: A set of tags. Jit request tags. + :vartype tags: dict[str, str] + """ + + _attribute_map = { + 'tags': {'key': 'tags', 'type': '{str}'}, + } + + def __init__( + self, + *, + tags: Optional[Dict[str, str]] = None, + **kwargs + ): + """ + :keyword tags: A set of tags. Jit request tags. + :paramtype tags: dict[str, str] + """ + super(JitRequestPatchable, self).__init__(**kwargs) + self.tags = tags + + +class JitSchedulingPolicy(msrest.serialization.Model): + """The JIT scheduling policies. + + All required parameters must be populated in order to send to Azure. + + :ivar type: Required. The type of JIT schedule. Known values are: "NotSpecified", "Once", + "Recurring". + :vartype type: str or ~azure.mgmt.managedapplication.v2018_03_01.models.JitSchedulingType + :ivar duration: Required. The required duration of the JIT request. + :vartype duration: ~datetime.timedelta + :ivar start_time: Required. The start time of the request. + :vartype start_time: ~datetime.datetime + """ + + _validation = { + 'type': {'required': True}, + 'duration': {'required': True}, + 'start_time': {'required': True}, + } + + _attribute_map = { + 'type': {'key': 'type', 'type': 'str'}, + 'duration': {'key': 'duration', 'type': 'duration'}, + 'start_time': {'key': 'startTime', 'type': 'iso-8601'}, + } + + def __init__( + self, + *, + type: Union[str, "_models.JitSchedulingType"], + duration: datetime.timedelta, + start_time: datetime.datetime, + **kwargs + ): + """ + :keyword type: Required. The type of JIT schedule. Known values are: "NotSpecified", "Once", + "Recurring". + :paramtype type: str or ~azure.mgmt.managedapplication.v2018_03_01.models.JitSchedulingType + :keyword duration: Required. The required duration of the JIT request. + :paramtype duration: ~datetime.timedelta + :keyword start_time: Required. The start time of the request. + :paramtype start_time: ~datetime.datetime + """ + super(JitSchedulingPolicy, self).__init__(**kwargs) + self.type = type + self.duration = duration + self.start_time = start_time + + +class ListTokenRequest(msrest.serialization.Model): + """List token request body. + + :ivar authorization_audience: The authorization audience. + :vartype authorization_audience: str + :ivar user_assigned_identities: The user assigned identities. + :vartype user_assigned_identities: list[str] + """ + + _attribute_map = { + 'authorization_audience': {'key': 'authorizationAudience', 'type': 'str'}, + 'user_assigned_identities': {'key': 'userAssignedIdentities', 'type': '[str]'}, + } + + def __init__( + self, + *, + authorization_audience: Optional[str] = None, + user_assigned_identities: Optional[List[str]] = None, + **kwargs + ): + """ + :keyword authorization_audience: The authorization audience. + :paramtype authorization_audience: str + :keyword user_assigned_identities: The user assigned identities. + :paramtype user_assigned_identities: list[str] + """ + super(ListTokenRequest, self).__init__(**kwargs) + self.authorization_audience = authorization_audience + self.user_assigned_identities = user_assigned_identities + + +class ManagedIdentityToken(msrest.serialization.Model): + """The managed identity token for the managed app resource. + + :ivar access_token: The requested access token. + :vartype access_token: str + :ivar expires_in: The number of seconds the access token will be valid. + :vartype expires_in: str + :ivar expires_on: The timespan when the access token expires. This is represented as the number + of seconds from epoch. + :vartype expires_on: str + :ivar not_before: The timespan when the access token takes effect. This is represented as the + number of seconds from epoch. + :vartype not_before: str + :ivar authorization_audience: The aud (audience) the access token was request for. This is the + same as what was provided in the listTokens request. + :vartype authorization_audience: str + :ivar resource_id: The Azure resource ID for the issued token. This is either the managed + application ID or the user-assigned identity ID. + :vartype resource_id: str + :ivar token_type: The type of the token. + :vartype token_type: str + """ + + _attribute_map = { + 'access_token': {'key': 'accessToken', 'type': 'str'}, + 'expires_in': {'key': 'expiresIn', 'type': 'str'}, + 'expires_on': {'key': 'expiresOn', 'type': 'str'}, + 'not_before': {'key': 'notBefore', 'type': 'str'}, + 'authorization_audience': {'key': 'authorizationAudience', 'type': 'str'}, + 'resource_id': {'key': 'resourceId', 'type': 'str'}, + 'token_type': {'key': 'tokenType', 'type': 'str'}, + } + + def __init__( + self, + *, + access_token: Optional[str] = None, + expires_in: Optional[str] = None, + expires_on: Optional[str] = None, + not_before: Optional[str] = None, + authorization_audience: Optional[str] = None, + resource_id: Optional[str] = None, + token_type: Optional[str] = None, + **kwargs + ): + """ + :keyword access_token: The requested access token. + :paramtype access_token: str + :keyword expires_in: The number of seconds the access token will be valid. + :paramtype expires_in: str + :keyword expires_on: The timespan when the access token expires. This is represented as the + number of seconds from epoch. + :paramtype expires_on: str + :keyword not_before: The timespan when the access token takes effect. This is represented as + the number of seconds from epoch. + :paramtype not_before: str + :keyword authorization_audience: The aud (audience) the access token was request for. This is + the same as what was provided in the listTokens request. + :paramtype authorization_audience: str + :keyword resource_id: The Azure resource ID for the issued token. This is either the managed + application ID or the user-assigned identity ID. + :paramtype resource_id: str + :keyword token_type: The type of the token. + :paramtype token_type: str + """ + super(ManagedIdentityToken, self).__init__(**kwargs) + self.access_token = access_token + self.expires_in = expires_in + self.expires_on = expires_on + self.not_before = not_before + self.authorization_audience = authorization_audience + self.resource_id = resource_id + self.token_type = token_type + + +class ManagedIdentityTokenResult(msrest.serialization.Model): + """The array of managed identity tokens. + + :ivar value: The array of managed identity tokens. + :vartype value: list[~azure.mgmt.managedapplication.v2018_03_01.models.ManagedIdentityToken] + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[ManagedIdentityToken]'}, + } + + def __init__( + self, + *, + value: Optional[List["_models.ManagedIdentityToken"]] = None, + **kwargs + ): + """ + :keyword value: The array of managed identity tokens. + :paramtype value: list[~azure.mgmt.managedapplication.v2018_03_01.models.ManagedIdentityToken] + """ + super(ManagedIdentityTokenResult, self).__init__(**kwargs) + self.value = value + + +class Operation(msrest.serialization.Model): + """Details of a REST API operation, returned from the Resource Provider Operations API. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name: The name of the operation, as per Resource-Based Access Control (RBAC). Examples: + "Microsoft.Compute/virtualMachines/write", "Microsoft.Compute/virtualMachines/capture/action". + :vartype name: str + :ivar is_data_action: Whether the operation applies to data-plane. This is "true" for + data-plane operations and "false" for ARM/control-plane operations. + :vartype is_data_action: bool + :ivar display: Localized display information for this particular operation. + :vartype display: ~azure.mgmt.managedapplication.v2018_03_01.models.OperationDisplay + :ivar origin: The intended executor of the operation; as in Resource Based Access Control + (RBAC) and audit logs UX. Default value is "user,system". Known values are: "user", "system", + "user,system". + :vartype origin: str or ~azure.mgmt.managedapplication.v2018_03_01.models.Origin + :ivar action_type: Enum. Indicates the action type. "Internal" refers to actions that are for + internal only APIs. Known values are: "Internal". + :vartype action_type: str or ~azure.mgmt.managedapplication.v2018_03_01.models.ActionType + """ + + _validation = { + 'name': {'readonly': True}, + 'is_data_action': {'readonly': True}, + 'origin': {'readonly': True}, + 'action_type': {'readonly': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'is_data_action': {'key': 'isDataAction', 'type': 'bool'}, + 'display': {'key': 'display', 'type': 'OperationDisplay'}, + 'origin': {'key': 'origin', 'type': 'str'}, + 'action_type': {'key': 'actionType', 'type': 'str'}, + } + + def __init__( + self, + *, + display: Optional["_models.OperationDisplay"] = None, + **kwargs + ): + """ + :keyword display: Localized display information for this particular operation. + :paramtype display: ~azure.mgmt.managedapplication.v2018_03_01.models.OperationDisplay + """ + super(Operation, self).__init__(**kwargs) + self.name = None + self.is_data_action = None + self.display = display + self.origin = None + self.action_type = None + + +class OperationAutoGenerated(msrest.serialization.Model): + """Microsoft.Solutions operation. + + :ivar name: Operation name: {provider}/{resource}/{operation}. + :vartype name: str + :ivar display: The object that represents the operation. + :vartype display: + ~azure.mgmt.managedapplication.v2018_03_01.models.OperationDisplayAutoGenerated + """ + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'display': {'key': 'display', 'type': 'OperationDisplayAutoGenerated'}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + display: Optional["_models.OperationDisplayAutoGenerated"] = None, + **kwargs + ): + """ + :keyword name: Operation name: {provider}/{resource}/{operation}. + :paramtype name: str + :keyword display: The object that represents the operation. + :paramtype display: + ~azure.mgmt.managedapplication.v2018_03_01.models.OperationDisplayAutoGenerated + """ + super(OperationAutoGenerated, self).__init__(**kwargs) + self.name = name + self.display = display + + +class OperationDisplay(msrest.serialization.Model): + """Localized display information for this particular operation. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar provider: The localized friendly form of the resource provider name, e.g. "Microsoft + Monitoring Insights" or "Microsoft Compute". + :vartype provider: str + :ivar resource: The localized friendly name of the resource type related to this operation. + E.g. "Virtual Machines" or "Job Schedule Collections". + :vartype resource: str + :ivar operation: The concise, localized friendly name for the operation; suitable for + dropdowns. E.g. "Create or Update Virtual Machine", "Restart Virtual Machine". + :vartype operation: str + :ivar description: The short, localized friendly description of the operation; suitable for + tool tips and detailed views. + :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 OperationDisplayAutoGenerated(msrest.serialization.Model): + """The object that represents the operation. + + :ivar provider: Service provider: Microsoft.Solutions. + :vartype provider: str + :ivar resource: Resource on which the operation is performed: Application, JitRequest, etc. + :vartype resource: str + :ivar operation: Operation type: Read, write, delete, etc. + :vartype operation: str + """ + + _attribute_map = { + 'provider': {'key': 'provider', 'type': 'str'}, + 'resource': {'key': 'resource', 'type': 'str'}, + 'operation': {'key': 'operation', 'type': 'str'}, + } + + def __init__( + self, + *, + provider: Optional[str] = None, + resource: Optional[str] = None, + operation: Optional[str] = None, + **kwargs + ): + """ + :keyword provider: Service provider: Microsoft.Solutions. + :paramtype provider: str + :keyword resource: Resource on which the operation is performed: Application, JitRequest, etc. + :paramtype resource: str + :keyword operation: Operation type: Read, write, delete, etc. + :paramtype operation: str + """ + super(OperationDisplayAutoGenerated, self).__init__(**kwargs) + self.provider = provider + self.resource = resource + self.operation = operation + + +class OperationListResult(msrest.serialization.Model): + """A list of REST API operations supported by an Azure Resource Provider. It contains an URL link to get the next set of results. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: List of operations supported by the resource provider. + :vartype value: list[~azure.mgmt.managedapplication.v2018_03_01.models.Operation] + :ivar next_link: URL to get the next set of operation list results (if there are any). + :vartype next_link: str + """ + + _validation = { + 'value': {'readonly': True}, + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Operation]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(OperationListResult, self).__init__(**kwargs) + self.value = None + self.next_link = None + + +class Plan(msrest.serialization.Model): + """Plan for the managed application. + + All required parameters must be populated in order to send to Azure. + + :ivar name: Required. The plan name. + :vartype name: str + :ivar publisher: Required. The publisher ID. + :vartype publisher: str + :ivar product: Required. The product code. + :vartype product: str + :ivar promotion_code: The promotion code. + :vartype promotion_code: str + :ivar version: Required. The plan's version. + :vartype version: str + """ + + _validation = { + 'name': {'required': True}, + 'publisher': {'required': True}, + 'product': {'required': True}, + 'version': {'required': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'publisher': {'key': 'publisher', 'type': 'str'}, + 'product': {'key': 'product', 'type': 'str'}, + 'promotion_code': {'key': 'promotionCode', 'type': 'str'}, + 'version': {'key': 'version', 'type': 'str'}, + } + + def __init__( + self, + *, + name: str, + publisher: str, + product: str, + version: str, + promotion_code: Optional[str] = None, + **kwargs + ): + """ + :keyword name: Required. The plan name. + :paramtype name: str + :keyword publisher: Required. The publisher ID. + :paramtype publisher: str + :keyword product: Required. The product code. + :paramtype product: str + :keyword promotion_code: The promotion code. + :paramtype promotion_code: str + :keyword version: Required. The plan's version. + :paramtype version: str + """ + super(Plan, self).__init__(**kwargs) + self.name = name + self.publisher = publisher + self.product = product + self.promotion_code = promotion_code + self.version = version + + +class PlanPatchable(msrest.serialization.Model): + """Plan for the managed application. + + :ivar name: The plan name. + :vartype name: str + :ivar publisher: The publisher ID. + :vartype publisher: str + :ivar product: The product code. + :vartype product: str + :ivar promotion_code: The promotion code. + :vartype promotion_code: str + :ivar version: The plan's version. + :vartype version: str + """ + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'publisher': {'key': 'publisher', 'type': 'str'}, + 'product': {'key': 'product', 'type': 'str'}, + 'promotion_code': {'key': 'promotionCode', 'type': 'str'}, + 'version': {'key': 'version', 'type': 'str'}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + publisher: Optional[str] = None, + product: Optional[str] = None, + promotion_code: Optional[str] = None, + version: Optional[str] = None, + **kwargs + ): + """ + :keyword name: The plan name. + :paramtype name: str + :keyword publisher: The publisher ID. + :paramtype publisher: str + :keyword product: The product code. + :paramtype product: str + :keyword promotion_code: The promotion code. + :paramtype promotion_code: str + :keyword version: The plan's version. + :paramtype version: str + """ + super(PlanPatchable, self).__init__(**kwargs) + self.name = name + self.publisher = publisher + self.product = product + self.promotion_code = promotion_code + self.version = version + + +class Sku(msrest.serialization.Model): + """SKU for the resource. + + All required parameters must be populated in order to send to Azure. + + :ivar name: Required. The SKU name. + :vartype name: str + :ivar tier: The SKU tier. + :vartype tier: str + :ivar size: The SKU size. + :vartype size: str + :ivar family: The SKU family. + :vartype family: str + :ivar model: The SKU model. + :vartype model: str + :ivar capacity: The SKU capacity. + :vartype capacity: int + """ + + _validation = { + 'name': {'required': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'tier': {'key': 'tier', 'type': 'str'}, + 'size': {'key': 'size', 'type': 'str'}, + 'family': {'key': 'family', 'type': 'str'}, + 'model': {'key': 'model', 'type': 'str'}, + 'capacity': {'key': 'capacity', 'type': 'int'}, + } + + def __init__( + self, + *, + name: str, + tier: Optional[str] = None, + size: Optional[str] = None, + family: Optional[str] = None, + model: Optional[str] = None, + capacity: Optional[int] = None, + **kwargs + ): + """ + :keyword name: Required. The SKU name. + :paramtype name: str + :keyword tier: The SKU tier. + :paramtype tier: str + :keyword size: The SKU size. + :paramtype size: str + :keyword family: The SKU family. + :paramtype family: str + :keyword model: The SKU model. + :paramtype model: str + :keyword capacity: The SKU capacity. + :paramtype capacity: int + """ + super(Sku, self).__init__(**kwargs) + self.name = name + self.tier = tier + self.size = size + self.family = family + self.model = model + self.capacity = capacity + + +class UpdateAccessDefinition(msrest.serialization.Model): + """Update access request definition. + + All required parameters must be populated in order to send to Azure. + + :ivar approver: The approver name. + :vartype approver: str + :ivar metadata: Required. The JIT request metadata. + :vartype metadata: ~azure.mgmt.managedapplication.v2018_03_01.models.JitRequestMetadata + :ivar status: Required. The JIT status. Known values are: "NotSpecified", "Elevate", "Remove". + :vartype status: str or ~azure.mgmt.managedapplication.v2018_03_01.models.Status + :ivar sub_status: Required. The JIT status. Known values are: "NotSpecified", "Approved", + "Denied", "Failed", "Expired", "Timeout". + :vartype sub_status: str or ~azure.mgmt.managedapplication.v2018_03_01.models.Substatus + """ + + _validation = { + 'metadata': {'required': True}, + 'status': {'required': True}, + 'sub_status': {'required': True}, + } + + _attribute_map = { + 'approver': {'key': 'approver', 'type': 'str'}, + 'metadata': {'key': 'metadata', 'type': 'JitRequestMetadata'}, + 'status': {'key': 'status', 'type': 'str'}, + 'sub_status': {'key': 'subStatus', 'type': 'str'}, + } + + def __init__( + self, + *, + metadata: "_models.JitRequestMetadata", + status: Union[str, "_models.Status"], + sub_status: Union[str, "_models.Substatus"], + approver: Optional[str] = None, + **kwargs + ): + """ + :keyword approver: The approver name. + :paramtype approver: str + :keyword metadata: Required. The JIT request metadata. + :paramtype metadata: ~azure.mgmt.managedapplication.v2018_03_01.models.JitRequestMetadata + :keyword status: Required. The JIT status. Known values are: "NotSpecified", "Elevate", + "Remove". + :paramtype status: str or ~azure.mgmt.managedapplication.v2018_03_01.models.Status + :keyword sub_status: Required. The JIT status. Known values are: "NotSpecified", "Approved", + "Denied", "Failed", "Expired", "Timeout". + :paramtype sub_status: str or ~azure.mgmt.managedapplication.v2018_03_01.models.Substatus + """ + super(UpdateAccessDefinition, self).__init__(**kwargs) + self.approver = approver + self.metadata = metadata + self.status = status + self.sub_status = sub_status + + +class UserAssignedResourceIdentity(msrest.serialization.Model): + """Represents the user assigned identity that is contained within the UserAssignedIdentities dictionary on ResourceIdentity. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar principal_id: The principal id of user assigned identity. + :vartype principal_id: str + :ivar tenant_id: The tenant id of user assigned identity. + :vartype tenant_id: str + """ + + _validation = { + 'principal_id': {'readonly': True}, + 'tenant_id': {'readonly': True}, + } + + _attribute_map = { + 'principal_id': {'key': 'principalId', 'type': 'str'}, + 'tenant_id': {'key': 'tenantId', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(UserAssignedResourceIdentity, self).__init__(**kwargs) + self.principal_id = None + self.tenant_id = None diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_03_01/models/_patch.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_03_01/models/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_03_01/models/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_03_01/operations/__init__.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_03_01/operations/__init__.py new file mode 100644 index 000000000000..b93ecbbe65e2 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_03_01/operations/__init__.py @@ -0,0 +1,24 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._application_client_operations import ApplicationClientOperationsMixin +from ._applications_operations import ApplicationsOperations +from ._application_definitions_operations import ApplicationDefinitionsOperations +from ._jit_requests_operations import JitRequestsOperations + +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk +__all__ = [ + 'ApplicationClientOperationsMixin', + 'ApplicationsOperations', + 'ApplicationDefinitionsOperations', + 'JitRequestsOperations', +] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_03_01/operations/_application_client_operations.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_03_01/operations/_application_client_operations.py new file mode 100644 index 000000000000..6791376cb7e9 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_03_01/operations/_application_client_operations.py @@ -0,0 +1,134 @@ +# 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.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._vendor import MixinABC, _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_operations_request( + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.Solutions/operations") + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + +class ApplicationClientOperationsMixin(MixinABC): + + @distributed_trace + def list_operations( + self, + **kwargs: Any + ) -> Iterable[_models.OperationListResult]: + """Lists all of the available Microsoft.Solutions REST API operations. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either OperationListResult or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.managedapplication.v2018_03_01.models.OperationListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01")) # 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', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_operations_request( + api_version=api_version, + template_url=self.list_operations.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_operations_request( + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list_operations.metadata = {'url': "/providers/Microsoft.Solutions/operations"} # type: ignore diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_03_01/operations/_application_definitions_operations.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_03_01/operations/_application_definitions_operations.py new file mode 100644 index 000000000000..a64bd80d324d --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_03_01/operations/_application_definitions_operations.py @@ -0,0 +1,1158 @@ +# 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.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._vendor import MixinABC, _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_request( + resource_group_name: str, + application_definition_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "applicationDefinitionName": _SERIALIZER.url("application_definition_name", application_definition_name, 'str', max_length=64, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_delete_request( + resource_group_name: str, + application_definition_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "applicationDefinitionName": _SERIALIZER.url("application_definition_name", application_definition_name, 'str', max_length=64, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_create_or_update_request( + resource_group_name: str, + application_definition_name: str, + subscription_id: str, + *, + json: Optional[_models.ApplicationDefinition] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "applicationDefinitionName": _SERIALIZER.url("application_definition_name", application_definition_name, 'str', max_length=64, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_update_request( + subscription_id: str, + resource_group_name: str, + application_definition_name: str, + *, + json: Optional[_models.ApplicationDefinitionPatchable] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "applicationDefinitionName": _SERIALIZER.url("application_definition_name", application_definition_name, 'str', max_length=64, min_length=3), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_list_by_resource_group_request( + resource_group_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_list_by_subscription_request( + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Solutions/applicationDefinitions") + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_get_by_id_request( + resource_group_name: str, + application_definition_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "applicationDefinitionName": _SERIALIZER.url("application_definition_name", application_definition_name, 'str', max_length=64, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_delete_by_id_request( + resource_group_name: str, + application_definition_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "applicationDefinitionName": _SERIALIZER.url("application_definition_name", application_definition_name, 'str', max_length=64, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_create_or_update_by_id_request( + resource_group_name: str, + application_definition_name: str, + subscription_id: str, + *, + json: Optional[_models.ApplicationDefinition] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "applicationDefinitionName": _SERIALIZER.url("application_definition_name", application_definition_name, 'str', max_length=64, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_update_by_id_request( + subscription_id: str, + resource_group_name: str, + application_definition_name: str, + *, + json: Optional[_models.ApplicationDefinitionPatchable] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "applicationDefinitionName": _SERIALIZER.url("application_definition_name", application_definition_name, 'str', max_length=64, min_length=3), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + +class ApplicationDefinitionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.managedapplication.v2018_03_01.ApplicationClient`'s + :attr:`application_definitions` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + + @distributed_trace + def get( + self, + resource_group_name: str, + application_definition_name: str, + **kwargs: Any + ) -> Optional[_models.ApplicationDefinition]: + """Gets the managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. + :type application_definition_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ApplicationDefinition, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2018_03_01.models.ApplicationDefinition or None + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.ApplicationDefinition]] + + + request = build_get_request( + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('ApplicationDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore + + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + application_definition_name: str, + **kwargs: Any + ) -> None: + """Deletes the managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition to delete. + :type application_definition_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_request( + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore + + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + application_definition_name: str, + parameters: _models.ApplicationDefinition, + **kwargs: Any + ) -> _models.ApplicationDefinition: + """Creates or update a managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. + :type application_definition_name: str + :param parameters: Parameters supplied to the create or update an managed application + definition. + :type parameters: ~azure.mgmt.managedapplication.v2018_03_01.models.ApplicationDefinition + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ApplicationDefinition, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2018_03_01.models.ApplicationDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationDefinition] + + _json = self._serialize.body(parameters, 'ApplicationDefinition') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # 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, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('ApplicationDefinition', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('ApplicationDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore + + + @distributed_trace + def update( + self, + resource_group_name: str, + application_definition_name: str, + parameters: _models.ApplicationDefinitionPatchable, + **kwargs: Any + ) -> _models.ApplicationDefinition: + """Updates the managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. + :type application_definition_name: str + :param parameters: Parameters supplied to the update a managed application definition. + :type parameters: + ~azure.mgmt.managedapplication.v2018_03_01.models.ApplicationDefinitionPatchable + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ApplicationDefinition, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2018_03_01.models.ApplicationDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationDefinition] + + _json = self._serialize.body(parameters, 'ApplicationDefinitionPatchable') + + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ApplicationDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore + + + @distributed_trace + def list_by_resource_group( + self, + resource_group_name: str, + **kwargs: Any + ) -> Iterable[_models.ApplicationDefinitionListResult]: + """Lists the managed application definitions in a resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ApplicationDefinitionListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.managedapplication.v2018_03_01.models.ApplicationDefinitionListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationDefinitionListResult] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_resource_group.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ApplicationDefinitionListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions"} # type: ignore + + @distributed_trace + def list_by_subscription( + self, + **kwargs: Any + ) -> Iterable[_models.ApplicationDefinitionListResult]: + """Lists the managed application definitions in a subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ApplicationDefinitionListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.managedapplication.v2018_03_01.models.ApplicationDefinitionListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationDefinitionListResult] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ApplicationDefinitionListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Solutions/applicationDefinitions"} # type: ignore + + @distributed_trace + def get_by_id( + self, + resource_group_name: str, + application_definition_name: str, + **kwargs: Any + ) -> Optional[_models.ApplicationDefinition]: + """Gets the managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. + :type application_definition_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ApplicationDefinition, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2018_03_01.models.ApplicationDefinition or None + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.ApplicationDefinition]] + + + request = build_get_by_id_request( + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_by_id.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('ApplicationDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_by_id.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore + + + @distributed_trace + def delete_by_id( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + application_definition_name: str, + **kwargs: Any + ) -> None: + """Deletes the managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. + :type application_definition_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_by_id_request( + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete_by_id.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete_by_id.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore + + + @distributed_trace + def create_or_update_by_id( + self, + resource_group_name: str, + application_definition_name: str, + parameters: _models.ApplicationDefinition, + **kwargs: Any + ) -> _models.ApplicationDefinition: + """Creates or updates a managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. + :type application_definition_name: str + :param parameters: Parameters supplied to the create or update a managed application + definition. + :type parameters: ~azure.mgmt.managedapplication.v2018_03_01.models.ApplicationDefinition + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ApplicationDefinition, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2018_03_01.models.ApplicationDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationDefinition] + + _json = self._serialize.body(parameters, 'ApplicationDefinition') + + request = build_create_or_update_by_id_request( + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + 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'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # 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, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('ApplicationDefinition', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('ApplicationDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_or_update_by_id.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore + + + @distributed_trace + def update_by_id( + self, + resource_group_name: str, + application_definition_name: str, + parameters: _models.ApplicationDefinitionPatchable, + **kwargs: Any + ) -> _models.ApplicationDefinition: + """Updates the managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. + :type application_definition_name: str + :param parameters: Parameters supplied to the update a managed application definition. + :type parameters: + ~azure.mgmt.managedapplication.v2018_03_01.models.ApplicationDefinitionPatchable + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ApplicationDefinition, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2018_03_01.models.ApplicationDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationDefinition] + + _json = self._serialize.body(parameters, 'ApplicationDefinitionPatchable') + + request = build_update_by_id_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.update_by_id.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ApplicationDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + update_by_id.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore + diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_03_01/operations/_applications_operations.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_03_01/operations/_applications_operations.py new file mode 100644 index 000000000000..8633b2d73331 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_03_01/operations/_applications_operations.py @@ -0,0 +1,1989 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast + +from msrest import Serializer + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from .._vendor import MixinABC, _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_request( + resource_group_name: str, + application_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "applicationName": _SERIALIZER.url("application_name", application_name, 'str', max_length=64, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_delete_request_initial( + resource_group_name: str, + application_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "applicationName": _SERIALIZER.url("application_name", application_name, 'str', max_length=64, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_create_or_update_request_initial( + resource_group_name: str, + application_name: str, + subscription_id: str, + *, + json: Optional[_models.Application] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "applicationName": _SERIALIZER.url("application_name", application_name, 'str', max_length=64, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_update_request_initial( + resource_group_name: str, + application_name: str, + subscription_id: str, + *, + json: Optional[_models.ApplicationPatchable] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "applicationName": _SERIALIZER.url("application_name", application_name, 'str', max_length=64, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_list_by_resource_group_request( + resource_group_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_list_by_subscription_request( + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Solutions/applications") + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_get_by_id_request( + application_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/{applicationId}") + path_format_arguments = { + "applicationId": _SERIALIZER.url("application_id", application_id, 'str', skip_quote=True), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_delete_by_id_request_initial( + application_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/{applicationId}") + path_format_arguments = { + "applicationId": _SERIALIZER.url("application_id", application_id, 'str', skip_quote=True), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_create_or_update_by_id_request_initial( + application_id: str, + *, + json: Optional[_models.Application] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/{applicationId}") + path_format_arguments = { + "applicationId": _SERIALIZER.url("application_id", application_id, 'str', skip_quote=True), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_update_by_id_request_initial( + application_id: str, + *, + json: Optional[_models.ApplicationPatchable] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/{applicationId}") + path_format_arguments = { + "applicationId": _SERIALIZER.url("application_id", application_id, 'str', skip_quote=True), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_refresh_permissions_request_initial( + resource_group_name: str, + application_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}/refreshPermissions") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "applicationName": _SERIALIZER.url("application_name", application_name, 'str', max_length=64, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_update_access_request_initial( + subscription_id: str, + resource_group_name: str, + application_name: str, + *, + json: Optional[_models.UpdateAccessDefinition] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}/updateAccess") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "applicationName": _SERIALIZER.url("application_name", application_name, 'str', max_length=64, min_length=3), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_list_tokens_request( + subscription_id: str, + resource_group_name: str, + application_name: str, + *, + json: Optional[_models.ListTokenRequest] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}/listTokens") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "applicationName": _SERIALIZER.url("application_name", application_name, 'str', max_length=64, min_length=3), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + +class ApplicationsOperations: # pylint: disable=too-many-public-methods + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.managedapplication.v2018_03_01.ApplicationClient`'s + :attr:`applications` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + + @distributed_trace + def get( + self, + resource_group_name: str, + application_name: str, + **kwargs: Any + ) -> Optional[_models.Application]: + """Gets the managed application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_name: The name of the managed application. + :type application_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Application, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2018_03_01.models.Application or None + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.Application]] + + + request = build_get_request( + resource_group_name=resource_group_name, + application_name=application_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('Application', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}"} # type: ignore + + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + application_name: str, + **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + application_name=application_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}"} # type: ignore + + + @distributed_trace + def begin_delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + application_name: str, + **kwargs: Any + ) -> LROPoller[None]: + """Deletes the managed application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_name: The name of the managed application. + :type application_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._delete_initial( # type: ignore + resource_group_name=resource_group_name, + application_name=application_name, + api_version=api_version, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}"} # type: ignore + + def _create_or_update_initial( + self, + resource_group_name: str, + application_name: str, + parameters: _models.Application, + **kwargs: Any + ) -> _models.Application: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Application] + + _json = self._serialize.body(parameters, 'Application') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + application_name=application_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('Application', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('Application', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}"} # type: ignore + + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + application_name: str, + parameters: _models.Application, + **kwargs: Any + ) -> LROPoller[_models.Application]: + """Creates or updates a managed application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_name: The name of the managed application. + :type application_name: str + :param parameters: Parameters supplied to the create or update a managed application. + :type parameters: ~azure.mgmt.managedapplication.v2018_03_01.models.Application + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Application or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.managedapplication.v2018_03_01.models.Application] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Application] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._create_or_update_initial( # type: ignore + resource_group_name=resource_group_name, + application_name=application_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('Application', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}"} # type: ignore + + def _update_initial( + self, + resource_group_name: str, + application_name: str, + parameters: Optional[_models.ApplicationPatchable] = None, + **kwargs: Any + ) -> _models.ApplicationPatchable: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationPatchable] + + if parameters is not None: + _json = self._serialize.body(parameters, 'ApplicationPatchable') + else: + _json = None + + request = build_update_request_initial( + resource_group_name=resource_group_name, + application_name=application_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('ApplicationPatchable', pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize('ApplicationPatchable', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}"} # type: ignore + + + @distributed_trace + def begin_update( + self, + resource_group_name: str, + application_name: str, + parameters: Optional[_models.ApplicationPatchable] = None, + **kwargs: Any + ) -> LROPoller[_models.ApplicationPatchable]: + """Updates an existing managed application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_name: The name of the managed application. + :type application_name: str + :param parameters: Parameters supplied to update an existing managed application. Default value + is None. + :type parameters: ~azure.mgmt.managedapplication.v2018_03_01.models.ApplicationPatchable + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ApplicationPatchable or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.managedapplication.v2018_03_01.models.ApplicationPatchable] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationPatchable] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._update_initial( # type: ignore + resource_group_name=resource_group_name, + application_name=application_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('ApplicationPatchable', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}"} # type: ignore + + @distributed_trace + def list_by_resource_group( + self, + resource_group_name: str, + **kwargs: Any + ) -> Iterable[_models.ApplicationListResult]: + """Lists all the applications within a resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ApplicationListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.managedapplication.v2018_03_01.models.ApplicationListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationListResult] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_resource_group.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ApplicationListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications"} # type: ignore + + @distributed_trace + def list_by_subscription( + self, + **kwargs: Any + ) -> Iterable[_models.ApplicationListResult]: + """Lists all the applications within a subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ApplicationListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.managedapplication.v2018_03_01.models.ApplicationListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationListResult] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ApplicationListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Solutions/applications"} # type: ignore + + @distributed_trace + def get_by_id( + self, + application_id: str, + **kwargs: Any + ) -> Optional[_models.Application]: + """Gets the managed application. + + :param application_id: The fully qualified ID of the managed application, including the managed + application name and the managed application resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/Microsoft.Solutions/applications/{application-name}. + :type application_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Application, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2018_03_01.models.Application or None + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.Application]] + + + request = build_get_by_id_request( + application_id=application_id, + api_version=api_version, + template_url=self.get_by_id.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('Application', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_by_id.metadata = {'url': "/{applicationId}"} # type: ignore + + + def _delete_by_id_initial( # pylint: disable=inconsistent-return-statements + self, + application_id: str, + **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_by_id_request_initial( + application_id=application_id, + api_version=api_version, + template_url=self._delete_by_id_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_by_id_initial.metadata = {'url': "/{applicationId}"} # type: ignore + + + @distributed_trace + def begin_delete_by_id( # pylint: disable=inconsistent-return-statements + self, + application_id: str, + **kwargs: Any + ) -> LROPoller[None]: + """Deletes the managed application. + + :param application_id: The fully qualified ID of the managed application, including the managed + application name and the managed application resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/Microsoft.Solutions/applications/{application-name}. + :type application_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._delete_by_id_initial( # type: ignore + application_id=application_id, + api_version=api_version, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete_by_id.metadata = {'url': "/{applicationId}"} # type: ignore + + def _create_or_update_by_id_initial( + self, + application_id: str, + parameters: _models.Application, + **kwargs: Any + ) -> _models.Application: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Application] + + _json = self._serialize.body(parameters, 'Application') + + request = build_create_or_update_by_id_request_initial( + application_id=application_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._create_or_update_by_id_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('Application', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('Application', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_by_id_initial.metadata = {'url': "/{applicationId}"} # type: ignore + + + @distributed_trace + def begin_create_or_update_by_id( + self, + application_id: str, + parameters: _models.Application, + **kwargs: Any + ) -> LROPoller[_models.Application]: + """Creates or updates a managed application. + + :param application_id: The fully qualified ID of the managed application, including the managed + application name and the managed application resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/Microsoft.Solutions/applications/{application-name}. + :type application_id: str + :param parameters: Parameters supplied to the create or update a managed application. + :type parameters: ~azure.mgmt.managedapplication.v2018_03_01.models.Application + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Application or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.managedapplication.v2018_03_01.models.Application] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Application] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._create_or_update_by_id_initial( # type: ignore + application_id=application_id, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('Application', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update_by_id.metadata = {'url': "/{applicationId}"} # type: ignore + + def _update_by_id_initial( + self, + application_id: str, + parameters: Optional[_models.ApplicationPatchable] = None, + **kwargs: Any + ) -> _models.ApplicationPatchable: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationPatchable] + + if parameters is not None: + _json = self._serialize.body(parameters, 'ApplicationPatchable') + else: + _json = None + + request = build_update_by_id_request_initial( + application_id=application_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._update_by_id_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('ApplicationPatchable', pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize('ApplicationPatchable', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _update_by_id_initial.metadata = {'url': "/{applicationId}"} # type: ignore + + + @distributed_trace + def begin_update_by_id( + self, + application_id: str, + parameters: Optional[_models.ApplicationPatchable] = None, + **kwargs: Any + ) -> LROPoller[_models.ApplicationPatchable]: + """Updates an existing managed application. + + :param application_id: The fully qualified ID of the managed application, including the managed + application name and the managed application resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/Microsoft.Solutions/applications/{application-name}. + :type application_id: str + :param parameters: Parameters supplied to update an existing managed application. Default value + is None. + :type parameters: ~azure.mgmt.managedapplication.v2018_03_01.models.ApplicationPatchable + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ApplicationPatchable or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.managedapplication.v2018_03_01.models.ApplicationPatchable] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationPatchable] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._update_by_id_initial( # type: ignore + application_id=application_id, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('ApplicationPatchable', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_update_by_id.metadata = {'url': "/{applicationId}"} # type: ignore + + def _refresh_permissions_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + application_name: str, + **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_refresh_permissions_request_initial( + resource_group_name=resource_group_name, + application_name=application_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._refresh_permissions_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _refresh_permissions_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}/refreshPermissions"} # type: ignore + + + @distributed_trace + def begin_refresh_permissions( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + application_name: str, + **kwargs: Any + ) -> LROPoller[None]: + """Refresh Permissions for application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_name: The name of the managed application. + :type application_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._refresh_permissions_initial( # type: ignore + resource_group_name=resource_group_name, + application_name=application_name, + api_version=api_version, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'location'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_refresh_permissions.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}/refreshPermissions"} # type: ignore + + def _update_access_initial( + self, + resource_group_name: str, + application_name: str, + parameters: _models.UpdateAccessDefinition, + **kwargs: Any + ) -> Optional[_models.UpdateAccessDefinition]: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.UpdateAccessDefinition]] + + _json = self._serialize.body(parameters, 'UpdateAccessDefinition') + + request = build_update_access_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + application_name=application_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._update_access_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 202: + deserialized = self._deserialize('UpdateAccessDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _update_access_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}/updateAccess"} # type: ignore + + + @distributed_trace + def begin_update_access( + self, + resource_group_name: str, + application_name: str, + parameters: _models.UpdateAccessDefinition, + **kwargs: Any + ) -> LROPoller[_models.UpdateAccessDefinition]: + """Update access for application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_name: The name of the managed application. + :type application_name: str + :param parameters: Request body parameters to update access. + :type parameters: ~azure.mgmt.managedapplication.v2018_03_01.models.UpdateAccessDefinition + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either UpdateAccessDefinition or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.managedapplication.v2018_03_01.models.UpdateAccessDefinition] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.UpdateAccessDefinition] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._update_access_initial( # type: ignore + resource_group_name=resource_group_name, + application_name=application_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('UpdateAccessDefinition', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'location'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_update_access.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}/updateAccess"} # type: ignore + + @distributed_trace + def list_tokens( + self, + resource_group_name: str, + application_name: str, + parameters: _models.ListTokenRequest, + **kwargs: Any + ) -> _models.ManagedIdentityTokenResult: + """List tokens for application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_name: The name of the managed application. + :type application_name: str + :param parameters: Request body parameters to list tokens. + :type parameters: ~azure.mgmt.managedapplication.v2018_03_01.models.ListTokenRequest + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ManagedIdentityTokenResult, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2018_03_01.models.ManagedIdentityTokenResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ManagedIdentityTokenResult] + + _json = self._serialize.body(parameters, 'ListTokenRequest') + + request = build_list_tokens_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + application_name=application_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.list_tokens.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ManagedIdentityTokenResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_tokens.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}/listTokens"} # type: ignore + diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_03_01/operations/_jit_requests_operations.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_03_01/operations/_jit_requests_operations.py new file mode 100644 index 000000000000..ba2e35fdf6d3 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_03_01/operations/_jit_requests_operations.py @@ -0,0 +1,736 @@ +# 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, Union, cast + +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.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from .._vendor import MixinABC, _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_request( + resource_group_name: str, + jit_request_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/jitRequests/{jitRequestName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "jitRequestName": _SERIALIZER.url("jit_request_name", jit_request_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_create_or_update_request_initial( + resource_group_name: str, + jit_request_name: str, + subscription_id: str, + *, + json: Optional[_models.JitRequestDefinition] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/jitRequests/{jitRequestName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "jitRequestName": _SERIALIZER.url("jit_request_name", jit_request_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_update_request( + resource_group_name: str, + jit_request_name: str, + subscription_id: str, + *, + json: Optional[_models.JitRequestPatchable] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/jitRequests/{jitRequestName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "jitRequestName": _SERIALIZER.url("jit_request_name", jit_request_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request( + resource_group_name: str, + jit_request_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/jitRequests/{jitRequestName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "jitRequestName": _SERIALIZER.url("jit_request_name", jit_request_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_list_by_subscription_request( + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Solutions/jitRequests") + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_list_by_resource_group_request( + resource_group_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/jitRequests") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + +class JitRequestsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.managedapplication.v2018_03_01.ApplicationClient`'s + :attr:`jit_requests` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + + @distributed_trace + def get( + self, + resource_group_name: str, + jit_request_name: str, + **kwargs: Any + ) -> Optional[_models.JitRequestDefinition]: + """Gets the JIT request. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param jit_request_name: The name of the JIT request. + :type jit_request_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JitRequestDefinition, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2018_03_01.models.JitRequestDefinition or None + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.JitRequestDefinition]] + + + request = build_get_request( + resource_group_name=resource_group_name, + jit_request_name=jit_request_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('JitRequestDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/jitRequests/{jitRequestName}"} # type: ignore + + + def _create_or_update_initial( + self, + resource_group_name: str, + jit_request_name: str, + parameters: _models.JitRequestDefinition, + **kwargs: Any + ) -> _models.JitRequestDefinition: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.JitRequestDefinition] + + _json = self._serialize.body(parameters, 'JitRequestDefinition') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + jit_request_name=jit_request_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('JitRequestDefinition', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('JitRequestDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/jitRequests/{jitRequestName}"} # type: ignore + + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + jit_request_name: str, + parameters: _models.JitRequestDefinition, + **kwargs: Any + ) -> LROPoller[_models.JitRequestDefinition]: + """Creates or updates the JIT request. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param jit_request_name: The name of the JIT request. + :type jit_request_name: str + :param parameters: Parameters supplied to the update JIT request. + :type parameters: ~azure.mgmt.managedapplication.v2018_03_01.models.JitRequestDefinition + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either JitRequestDefinition or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.managedapplication.v2018_03_01.models.JitRequestDefinition] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.JitRequestDefinition] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._create_or_update_initial( # type: ignore + resource_group_name=resource_group_name, + jit_request_name=jit_request_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('JitRequestDefinition', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/jitRequests/{jitRequestName}"} # type: ignore + + @distributed_trace + def update( + self, + resource_group_name: str, + jit_request_name: str, + parameters: _models.JitRequestPatchable, + **kwargs: Any + ) -> _models.JitRequestDefinition: + """Updates the JIT request. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param jit_request_name: The name of the JIT request. + :type jit_request_name: str + :param parameters: Parameters supplied to the update JIT request. + :type parameters: ~azure.mgmt.managedapplication.v2018_03_01.models.JitRequestPatchable + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JitRequestDefinition, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2018_03_01.models.JitRequestDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.JitRequestDefinition] + + _json = self._serialize.body(parameters, 'JitRequestPatchable') + + request = build_update_request( + resource_group_name=resource_group_name, + jit_request_name=jit_request_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('JitRequestDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/jitRequests/{jitRequestName}"} # type: ignore + + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + jit_request_name: str, + **kwargs: Any + ) -> None: + """Deletes the JIT request. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param jit_request_name: The name of the JIT request. + :type jit_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 + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_request( + resource_group_name=resource_group_name, + jit_request_name=jit_request_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/jitRequests/{jitRequestName}"} # type: ignore + + + @distributed_trace + def list_by_subscription( + self, + **kwargs: Any + ) -> _models.JitRequestDefinitionListResult: + """Lists all JIT requests within the subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JitRequestDefinitionListResult, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2018_03_01.models.JitRequestDefinitionListResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.JitRequestDefinitionListResult] + + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('JitRequestDefinitionListResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Solutions/jitRequests"} # type: ignore + + + @distributed_trace + def list_by_resource_group( + self, + resource_group_name: str, + **kwargs: Any + ) -> _models.JitRequestDefinitionListResult: + """Lists all JIT requests within the 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: JitRequestDefinitionListResult, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2018_03_01.models.JitRequestDefinitionListResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.JitRequestDefinitionListResult] + + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_resource_group.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('JitRequestDefinitionListResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/jitRequests"} # type: ignore + diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_03_01/operations/_patch.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_03_01/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_03_01/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_03_01/py.typed b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_03_01/py.typed new file mode 100644 index 000000000000..e5aff4f83af8 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_03_01/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_06_01/__init__.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_06_01/__init__.py new file mode 100644 index 000000000000..2e61ca12e56a --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_06_01/__init__.py @@ -0,0 +1,23 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._application_client import ApplicationClient +from ._version import VERSION + +__version__ = VERSION + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk +__all__ = ['ApplicationClient'] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_06_01/_application_client.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_06_01/_application_client.py new file mode 100644 index 000000000000..19643f066d3c --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_06_01/_application_client.py @@ -0,0 +1,112 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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 ApplicationClientConfiguration +from .operations import ApplicationClientOperationsMixin, ApplicationDefinitionsOperations, ApplicationsOperations, JitRequestsOperations + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential + +class ApplicationClient(ApplicationClientOperationsMixin): + """ARM applications. + + :ivar applications: ApplicationsOperations operations + :vartype applications: + azure.mgmt.managedapplication.v2018_06_01.operations.ApplicationsOperations + :ivar application_definitions: ApplicationDefinitionsOperations operations + :vartype application_definitions: + azure.mgmt.managedapplication.v2018_06_01.operations.ApplicationDefinitionsOperations + :ivar jit_requests: JitRequestsOperations operations + :vartype jit_requests: + azure.mgmt.managedapplication.v2018_06_01.operations.JitRequestsOperations + :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 "2018-06-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + """ + + def __init__( + self, + credential: "TokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = ApplicationClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.applications = ApplicationsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.application_definitions = ApplicationDefinitionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.jit_requests = JitRequestsOperations( + 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: () -> ApplicationClient + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (Any) -> None + self._client.__exit__(*exc_details) diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_06_01/_configuration.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_06_01/_configuration.py new file mode 100644 index 000000000000..e0f22fd4a371 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_06_01/_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 ApplicationClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes + """Configuration for ApplicationClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials.TokenCredential + :param subscription_id: The ID of the target subscription. + :type subscription_id: str + :keyword api_version: Api Version. Default value is "2018-06-01". 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(ApplicationClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2018-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.") + + 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-managedapplication/{}'.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/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_06_01/_metadata.json b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_06_01/_metadata.json new file mode 100644 index 000000000000..809608dbbe2d --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_06_01/_metadata.json @@ -0,0 +1,123 @@ +{ + "chosen_version": "2018-06-01", + "total_api_version_list": ["2018-06-01"], + "client": { + "name": "ApplicationClient", + "filename": "_application_client", + "description": "ARM applications.", + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": null, + "azure_arm": true, + "has_lro_operations": true, + "client_side_validation": false, + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ApplicationClientConfiguration\"], \"._operations_mixin\": [\"ApplicationClientOperationsMixin\"]}, \"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\": [\"ApplicationClientConfiguration\"], \"._operations_mixin\": [\"ApplicationClientOperationsMixin\"]}, \"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": { + "applications": "ApplicationsOperations", + "application_definitions": "ApplicationDefinitionsOperations", + "jit_requests": "JitRequestsOperations" + }, + "operation_mixins": { + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Iterable\"]}, \"azurecore\": {\"azure.core.paging\": [\"ItemPaged\"]}}, \"regular\": {\"local\": {\".\": [[\"models\", \"_models\"]]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"AsyncIterable\"]}, \"azurecore\": {\"azure.core.async_paging\": [\"AsyncItemPaged\"]}}, \"regular\": {\"local\": {\"..\": [[\"models\", \"_models\"]]}}}", + "operations": { + "list_operations" : { + "sync": { + "signature": "def list_operations(\n self,\n **kwargs # type: Any\n):\n # type: (...) -\u003e Iterable[_models.OperationListResult]\n", + "doc": "\"\"\"Lists all of the available Microsoft.Solutions REST API operations.\n\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: An iterator like instance of either OperationListResult or the result of cls(response)\n:rtype:\n ~azure.core.paging.ItemPaged[~azure.mgmt.managedapplication.v2018_06_01.models.OperationListResult]\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"", + "call": "**kwargs" + }, + "async": { + "coroutine": false, + "signature": "def list_operations(\n self,\n **kwargs: Any\n) -\u003e AsyncIterable[_models.OperationListResult]:\n", + "doc": "\"\"\"Lists all of the available Microsoft.Solutions REST API operations.\n\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: An iterator like instance of either OperationListResult or the result of cls(response)\n:rtype:\n ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.managedapplication.v2018_06_01.models.OperationListResult]\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"", + "call": "**kwargs" + } + } + } + } +} \ No newline at end of file diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_06_01/_patch.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_06_01/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_06_01/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_06_01/_vendor.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_06_01/_vendor.py new file mode 100644 index 000000000000..bf1845cabc0f --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_06_01/_vendor.py @@ -0,0 +1,45 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from abc import ABC +from typing import TYPE_CHECKING + +from azure.core.pipeline.transport import HttpRequest + +from ._configuration import ApplicationClientConfiguration + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from msrest import Deserializer, Serializer + + from azure.core import PipelineClient + +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) + +class MixinABC(ABC): + """DO NOT use this class. It is for internal typing use only.""" + _client: "PipelineClient" + _config: ApplicationClientConfiguration + _serialize: "Serializer" + _deserialize: "Deserializer" diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_06_01/_version.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_06_01/_version.py new file mode 100644 index 000000000000..e5754a47ce68 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_06_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/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_06_01/aio/__init__.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_06_01/aio/__init__.py new file mode 100644 index 000000000000..c90626a31421 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_06_01/aio/__init__.py @@ -0,0 +1,20 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._application_client import ApplicationClient + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk +__all__ = ['ApplicationClient'] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_06_01/aio/_application_client.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_06_01/aio/_application_client.py new file mode 100644 index 000000000000..207d1a4837d5 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_06_01/aio/_application_client.py @@ -0,0 +1,109 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# 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 ApplicationClientConfiguration +from .operations import ApplicationClientOperationsMixin, ApplicationDefinitionsOperations, ApplicationsOperations, JitRequestsOperations + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + +class ApplicationClient(ApplicationClientOperationsMixin): + """ARM applications. + + :ivar applications: ApplicationsOperations operations + :vartype applications: + azure.mgmt.managedapplication.v2018_06_01.aio.operations.ApplicationsOperations + :ivar application_definitions: ApplicationDefinitionsOperations operations + :vartype application_definitions: + azure.mgmt.managedapplication.v2018_06_01.aio.operations.ApplicationDefinitionsOperations + :ivar jit_requests: JitRequestsOperations operations + :vartype jit_requests: + azure.mgmt.managedapplication.v2018_06_01.aio.operations.JitRequestsOperations + :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 "2018-06-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = ApplicationClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.applications = ApplicationsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.application_definitions = ApplicationDefinitionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.jit_requests = JitRequestsOperations( + 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) -> "ApplicationClient": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_06_01/aio/_configuration.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_06_01/aio/_configuration.py new file mode 100644 index 000000000000..23d00511d06d --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_06_01/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 ApplicationClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes + """Configuration for ApplicationClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :param subscription_id: The ID of the target subscription. + :type subscription_id: str + :keyword api_version: Api Version. Default value is "2018-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, + **kwargs: Any + ) -> None: + super(ApplicationClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2018-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.") + + 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-managedapplication/{}'.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/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_06_01/aio/_patch.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_06_01/aio/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_06_01/aio/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_06_01/aio/_vendor.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_06_01/aio/_vendor.py new file mode 100644 index 000000000000..da14e4f71f0e --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_06_01/aio/_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 abc import ABC +from typing import TYPE_CHECKING + +from azure.core.pipeline.transport import HttpRequest + +from ._configuration import ApplicationClientConfiguration + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from msrest import Deserializer, Serializer + + from azure.core import AsyncPipelineClient + + +class MixinABC(ABC): + """DO NOT use this class. It is for internal typing use only.""" + _client: "AsyncPipelineClient" + _config: ApplicationClientConfiguration + _serialize: "Serializer" + _deserialize: "Deserializer" diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_06_01/aio/operations/__init__.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_06_01/aio/operations/__init__.py new file mode 100644 index 000000000000..b93ecbbe65e2 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_06_01/aio/operations/__init__.py @@ -0,0 +1,24 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._application_client_operations import ApplicationClientOperationsMixin +from ._applications_operations import ApplicationsOperations +from ._application_definitions_operations import ApplicationDefinitionsOperations +from ._jit_requests_operations import JitRequestsOperations + +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk +__all__ = [ + 'ApplicationClientOperationsMixin', + 'ApplicationsOperations', + 'ApplicationDefinitionsOperations', + 'JitRequestsOperations', +] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_06_01/aio/operations/_application_client_operations.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_06_01/aio/operations/_application_client_operations.py new file mode 100644 index 000000000000..48ef4064309b --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_06_01/aio/operations/_application_client_operations.py @@ -0,0 +1,105 @@ +# 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.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._application_client_operations import build_list_operations_request +from .._vendor import MixinABC +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class ApplicationClientOperationsMixin(MixinABC): + + @distributed_trace + def list_operations( + self, + **kwargs: Any + ) -> AsyncIterable[_models.OperationListResult]: + """Lists all of the available Microsoft.Solutions REST API operations. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either OperationListResult or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.managedapplication.v2018_06_01.models.OperationListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # 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', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_operations_request( + api_version=api_version, + template_url=self.list_operations.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_operations_request( + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list_operations.metadata = {'url': "/providers/Microsoft.Solutions/operations"} # type: ignore diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_06_01/aio/operations/_application_definitions_operations.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_06_01/aio/operations/_application_definitions_operations.py new file mode 100644 index 000000000000..d0e4bdb20c6a --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_06_01/aio/operations/_application_definitions_operations.py @@ -0,0 +1,761 @@ +# 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.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._application_definitions_operations import build_create_or_update_by_id_request, build_create_or_update_request, build_delete_by_id_request, build_delete_request, build_get_by_id_request, build_get_request, build_list_by_resource_group_request, build_list_by_subscription_request, build_update_by_id_request, build_update_request +from .._vendor import MixinABC +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class ApplicationDefinitionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.managedapplication.v2018_06_01.aio.ApplicationClient`'s + :attr:`application_definitions` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + application_definition_name: str, + **kwargs: Any + ) -> Optional[_models.ApplicationDefinition]: + """Gets the managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. + :type application_definition_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ApplicationDefinition, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2018_06_01.models.ApplicationDefinition or None + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.ApplicationDefinition]] + + + request = build_get_request( + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('ApplicationDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore + + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + application_definition_name: str, + **kwargs: Any + ) -> None: + """Deletes the managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition to delete. + :type application_definition_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_request( + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore + + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + application_definition_name: str, + parameters: _models.ApplicationDefinition, + **kwargs: Any + ) -> _models.ApplicationDefinition: + """Creates or updates a managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. + :type application_definition_name: str + :param parameters: Parameters supplied to the create or update an managed application + definition. + :type parameters: ~azure.mgmt.managedapplication.v2018_06_01.models.ApplicationDefinition + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ApplicationDefinition, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2018_06_01.models.ApplicationDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationDefinition] + + _json = self._serialize.body(parameters, 'ApplicationDefinition') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # 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, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('ApplicationDefinition', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('ApplicationDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore + + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + application_definition_name: str, + parameters: _models.ApplicationDefinitionPatchable, + **kwargs: Any + ) -> _models.ApplicationDefinition: + """Updates the managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. + :type application_definition_name: str + :param parameters: Parameters supplied to the update a managed application definition. + :type parameters: + ~azure.mgmt.managedapplication.v2018_06_01.models.ApplicationDefinitionPatchable + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ApplicationDefinition, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2018_06_01.models.ApplicationDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationDefinition] + + _json = self._serialize.body(parameters, 'ApplicationDefinitionPatchable') + + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ApplicationDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore + + + @distributed_trace + def list_by_resource_group( + self, + resource_group_name: str, + **kwargs: Any + ) -> AsyncIterable[_models.ApplicationDefinitionListResult]: + """Lists the managed application definitions in a resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ApplicationDefinitionListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.managedapplication.v2018_06_01.models.ApplicationDefinitionListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationDefinitionListResult] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_resource_group.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ApplicationDefinitionListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions"} # type: ignore + + @distributed_trace + def list_by_subscription( + self, + **kwargs: Any + ) -> AsyncIterable[_models.ApplicationDefinitionListResult]: + """Lists the managed application definitions in a subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ApplicationDefinitionListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.managedapplication.v2018_06_01.models.ApplicationDefinitionListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationDefinitionListResult] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ApplicationDefinitionListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Solutions/applicationDefinitions"} # type: ignore + + @distributed_trace_async + async def get_by_id( + self, + resource_group_name: str, + application_definition_name: str, + **kwargs: Any + ) -> Optional[_models.ApplicationDefinition]: + """Gets the managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. + :type application_definition_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ApplicationDefinition, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2018_06_01.models.ApplicationDefinition or None + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.ApplicationDefinition]] + + + request = build_get_by_id_request( + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_by_id.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('ApplicationDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_by_id.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore + + + @distributed_trace_async + async def delete_by_id( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + application_definition_name: str, + **kwargs: Any + ) -> None: + """Deletes the managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. + :type application_definition_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_by_id_request( + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete_by_id.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete_by_id.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore + + + @distributed_trace_async + async def create_or_update_by_id( + self, + resource_group_name: str, + application_definition_name: str, + parameters: _models.ApplicationDefinition, + **kwargs: Any + ) -> _models.ApplicationDefinition: + """Creates or updates a managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. + :type application_definition_name: str + :param parameters: Parameters supplied to the create or update a managed application + definition. + :type parameters: ~azure.mgmt.managedapplication.v2018_06_01.models.ApplicationDefinition + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ApplicationDefinition, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2018_06_01.models.ApplicationDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationDefinition] + + _json = self._serialize.body(parameters, 'ApplicationDefinition') + + request = build_create_or_update_by_id_request( + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + 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'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # 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, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('ApplicationDefinition', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('ApplicationDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_or_update_by_id.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore + + + @distributed_trace_async + async def update_by_id( + self, + resource_group_name: str, + application_definition_name: str, + parameters: _models.ApplicationDefinitionPatchable, + **kwargs: Any + ) -> _models.ApplicationDefinition: + """Updates the managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. + :type application_definition_name: str + :param parameters: Parameters supplied to the update a managed application definition. + :type parameters: + ~azure.mgmt.managedapplication.v2018_06_01.models.ApplicationDefinitionPatchable + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ApplicationDefinition, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2018_06_01.models.ApplicationDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationDefinition] + + _json = self._serialize.body(parameters, 'ApplicationDefinitionPatchable') + + request = build_update_by_id_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.update_by_id.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ApplicationDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + update_by_id.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore + diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_06_01/aio/operations/_applications_operations.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_06_01/aio/operations/_applications_operations.py new file mode 100644 index 000000000000..12911118ca77 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_06_01/aio/operations/_applications_operations.py @@ -0,0 +1,1481 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union, cast + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._applications_operations import build_create_or_update_by_id_request_initial, build_create_or_update_request_initial, build_delete_by_id_request_initial, build_delete_request_initial, build_get_by_id_request, build_get_request, build_list_by_resource_group_request, build_list_by_subscription_request, build_list_tokens_request, build_refresh_permissions_request_initial, build_update_access_request_initial, build_update_by_id_request_initial, build_update_request_initial +from .._vendor import MixinABC +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class ApplicationsOperations: # pylint: disable=too-many-public-methods + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.managedapplication.v2018_06_01.aio.ApplicationClient`'s + :attr:`applications` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + application_name: str, + **kwargs: Any + ) -> Optional[_models.Application]: + """Gets the managed application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_name: The name of the managed application. + :type application_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Application, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2018_06_01.models.Application or None + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.Application]] + + + request = build_get_request( + resource_group_name=resource_group_name, + application_name=application_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('Application', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}"} # type: ignore + + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + application_name: str, + **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + application_name=application_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}"} # type: ignore + + + @distributed_trace_async + async def begin_delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + application_name: str, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes the managed application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_name: The name of the managed application. + :type application_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._delete_initial( # type: ignore + resource_group_name=resource_group_name, + application_name=application_name, + api_version=api_version, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}"} # type: ignore + + async def _create_or_update_initial( + self, + resource_group_name: str, + application_name: str, + parameters: _models.Application, + **kwargs: Any + ) -> _models.Application: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Application] + + _json = self._serialize.body(parameters, 'Application') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + application_name=application_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('Application', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('Application', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}"} # type: ignore + + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + application_name: str, + parameters: _models.Application, + **kwargs: Any + ) -> AsyncLROPoller[_models.Application]: + """Creates or updates a managed application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_name: The name of the managed application. + :type application_name: str + :param parameters: Parameters supplied to the create or update a managed application. + :type parameters: ~azure.mgmt.managedapplication.v2018_06_01.models.Application + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either Application or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.managedapplication.v2018_06_01.models.Application] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Application] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._create_or_update_initial( # type: ignore + resource_group_name=resource_group_name, + application_name=application_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('Application', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}"} # type: ignore + + async def _update_initial( + self, + resource_group_name: str, + application_name: str, + parameters: Optional[_models.ApplicationPatchable] = None, + **kwargs: Any + ) -> _models.ApplicationPatchable: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationPatchable] + + if parameters is not None: + _json = self._serialize.body(parameters, 'ApplicationPatchable') + else: + _json = None + + request = build_update_request_initial( + resource_group_name=resource_group_name, + application_name=application_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('ApplicationPatchable', pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize('ApplicationPatchable', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}"} # type: ignore + + + @distributed_trace_async + async def begin_update( + self, + resource_group_name: str, + application_name: str, + parameters: Optional[_models.ApplicationPatchable] = None, + **kwargs: Any + ) -> AsyncLROPoller[_models.ApplicationPatchable]: + """Updates an existing managed application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_name: The name of the managed application. + :type application_name: str + :param parameters: Parameters supplied to update an existing managed application. Default value + is None. + :type parameters: ~azure.mgmt.managedapplication.v2018_06_01.models.ApplicationPatchable + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ApplicationPatchable or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.managedapplication.v2018_06_01.models.ApplicationPatchable] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationPatchable] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._update_initial( # type: ignore + resource_group_name=resource_group_name, + application_name=application_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('ApplicationPatchable', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}"} # type: ignore + + @distributed_trace + def list_by_resource_group( + self, + resource_group_name: str, + **kwargs: Any + ) -> AsyncIterable[_models.ApplicationListResult]: + """Lists all the applications within a resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ApplicationListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.managedapplication.v2018_06_01.models.ApplicationListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationListResult] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_resource_group.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ApplicationListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications"} # type: ignore + + @distributed_trace + def list_by_subscription( + self, + **kwargs: Any + ) -> AsyncIterable[_models.ApplicationListResult]: + """Lists all the applications within a subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ApplicationListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.managedapplication.v2018_06_01.models.ApplicationListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationListResult] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ApplicationListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Solutions/applications"} # type: ignore + + @distributed_trace_async + async def get_by_id( + self, + application_id: str, + **kwargs: Any + ) -> Optional[_models.Application]: + """Gets the managed application. + + :param application_id: The fully qualified ID of the managed application, including the managed + application name and the managed application resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/Microsoft.Solutions/applications/{application-name}. + :type application_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Application, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2018_06_01.models.Application or None + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.Application]] + + + request = build_get_by_id_request( + application_id=application_id, + api_version=api_version, + template_url=self.get_by_id.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('Application', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_by_id.metadata = {'url': "/{applicationId}"} # type: ignore + + + async def _delete_by_id_initial( # pylint: disable=inconsistent-return-statements + self, + application_id: str, + **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_by_id_request_initial( + application_id=application_id, + api_version=api_version, + template_url=self._delete_by_id_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_by_id_initial.metadata = {'url': "/{applicationId}"} # type: ignore + + + @distributed_trace_async + async def begin_delete_by_id( # pylint: disable=inconsistent-return-statements + self, + application_id: str, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes the managed application. + + :param application_id: The fully qualified ID of the managed application, including the managed + application name and the managed application resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/Microsoft.Solutions/applications/{application-name}. + :type application_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._delete_by_id_initial( # type: ignore + application_id=application_id, + api_version=api_version, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete_by_id.metadata = {'url': "/{applicationId}"} # type: ignore + + async def _create_or_update_by_id_initial( + self, + application_id: str, + parameters: _models.Application, + **kwargs: Any + ) -> _models.Application: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Application] + + _json = self._serialize.body(parameters, 'Application') + + request = build_create_or_update_by_id_request_initial( + application_id=application_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._create_or_update_by_id_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('Application', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('Application', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_by_id_initial.metadata = {'url': "/{applicationId}"} # type: ignore + + + @distributed_trace_async + async def begin_create_or_update_by_id( + self, + application_id: str, + parameters: _models.Application, + **kwargs: Any + ) -> AsyncLROPoller[_models.Application]: + """Creates or updates a managed application. + + :param application_id: The fully qualified ID of the managed application, including the managed + application name and the managed application resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/Microsoft.Solutions/applications/{application-name}. + :type application_id: str + :param parameters: Parameters supplied to the create or update a managed application. + :type parameters: ~azure.mgmt.managedapplication.v2018_06_01.models.Application + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either Application or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.managedapplication.v2018_06_01.models.Application] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Application] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._create_or_update_by_id_initial( # type: ignore + application_id=application_id, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('Application', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update_by_id.metadata = {'url': "/{applicationId}"} # type: ignore + + async def _update_by_id_initial( + self, + application_id: str, + parameters: Optional[_models.ApplicationPatchable] = None, + **kwargs: Any + ) -> _models.ApplicationPatchable: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationPatchable] + + if parameters is not None: + _json = self._serialize.body(parameters, 'ApplicationPatchable') + else: + _json = None + + request = build_update_by_id_request_initial( + application_id=application_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._update_by_id_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('ApplicationPatchable', pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize('ApplicationPatchable', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _update_by_id_initial.metadata = {'url': "/{applicationId}"} # type: ignore + + + @distributed_trace_async + async def begin_update_by_id( + self, + application_id: str, + parameters: Optional[_models.ApplicationPatchable] = None, + **kwargs: Any + ) -> AsyncLROPoller[_models.ApplicationPatchable]: + """Updates an existing managed application. + + :param application_id: The fully qualified ID of the managed application, including the managed + application name and the managed application resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/Microsoft.Solutions/applications/{application-name}. + :type application_id: str + :param parameters: Parameters supplied to update an existing managed application. Default value + is None. + :type parameters: ~azure.mgmt.managedapplication.v2018_06_01.models.ApplicationPatchable + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ApplicationPatchable or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.managedapplication.v2018_06_01.models.ApplicationPatchable] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationPatchable] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._update_by_id_initial( # type: ignore + application_id=application_id, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('ApplicationPatchable', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_update_by_id.metadata = {'url': "/{applicationId}"} # type: ignore + + async def _refresh_permissions_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + application_name: str, + **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_refresh_permissions_request_initial( + resource_group_name=resource_group_name, + application_name=application_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._refresh_permissions_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _refresh_permissions_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}/refreshPermissions"} # type: ignore + + + @distributed_trace_async + async def begin_refresh_permissions( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + application_name: str, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Refresh Permissions for application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_name: The name of the managed application. + :type application_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._refresh_permissions_initial( # type: ignore + resource_group_name=resource_group_name, + application_name=application_name, + api_version=api_version, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'location'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_refresh_permissions.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}/refreshPermissions"} # type: ignore + + async def _update_access_initial( + self, + resource_group_name: str, + application_name: str, + parameters: _models.UpdateAccessDefinition, + **kwargs: Any + ) -> Optional[_models.UpdateAccessDefinition]: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.UpdateAccessDefinition]] + + _json = self._serialize.body(parameters, 'UpdateAccessDefinition') + + request = build_update_access_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + application_name=application_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._update_access_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 202: + deserialized = self._deserialize('UpdateAccessDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _update_access_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}/updateAccess"} # type: ignore + + + @distributed_trace_async + async def begin_update_access( + self, + resource_group_name: str, + application_name: str, + parameters: _models.UpdateAccessDefinition, + **kwargs: Any + ) -> AsyncLROPoller[_models.UpdateAccessDefinition]: + """Update access for application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_name: The name of the managed application. + :type application_name: str + :param parameters: Request body parameters to update access. + :type parameters: ~azure.mgmt.managedapplication.v2018_06_01.models.UpdateAccessDefinition + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either UpdateAccessDefinition or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.managedapplication.v2018_06_01.models.UpdateAccessDefinition] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.UpdateAccessDefinition] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._update_access_initial( # type: ignore + resource_group_name=resource_group_name, + application_name=application_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('UpdateAccessDefinition', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'location'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_update_access.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}/updateAccess"} # type: ignore + + @distributed_trace_async + async def list_tokens( + self, + resource_group_name: str, + application_name: str, + parameters: _models.ListTokenRequest, + **kwargs: Any + ) -> _models.ManagedIdentityTokenResult: + """List tokens for application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_name: The name of the managed application. + :type application_name: str + :param parameters: Request body parameters to list tokens. + :type parameters: ~azure.mgmt.managedapplication.v2018_06_01.models.ListTokenRequest + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ManagedIdentityTokenResult, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2018_06_01.models.ManagedIdentityTokenResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ManagedIdentityTokenResult] + + _json = self._serialize.body(parameters, 'ListTokenRequest') + + request = build_list_tokens_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + application_name=application_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.list_tokens.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ManagedIdentityTokenResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_tokens.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}/listTokens"} # type: ignore + diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_06_01/aio/operations/_jit_requests_operations.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_06_01/aio/operations/_jit_requests_operations.py new file mode 100644 index 000000000000..6159bde2c4dd --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_06_01/aio/operations/_jit_requests_operations.py @@ -0,0 +1,502 @@ +# 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, Union, cast + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._jit_requests_operations import build_create_or_update_request_initial, build_delete_request, build_get_request, build_list_by_resource_group_request, build_list_by_subscription_request, build_update_request +from .._vendor import MixinABC +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class JitRequestsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.managedapplication.v2018_06_01.aio.ApplicationClient`'s + :attr:`jit_requests` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + jit_request_name: str, + **kwargs: Any + ) -> Optional[_models.JitRequestDefinition]: + """Gets the JIT request. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param jit_request_name: The name of the JIT request. + :type jit_request_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JitRequestDefinition, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2018_06_01.models.JitRequestDefinition or None + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.JitRequestDefinition]] + + + request = build_get_request( + resource_group_name=resource_group_name, + jit_request_name=jit_request_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('JitRequestDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/jitRequests/{jitRequestName}"} # type: ignore + + + async def _create_or_update_initial( + self, + resource_group_name: str, + jit_request_name: str, + parameters: _models.JitRequestDefinition, + **kwargs: Any + ) -> _models.JitRequestDefinition: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.JitRequestDefinition] + + _json = self._serialize.body(parameters, 'JitRequestDefinition') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + jit_request_name=jit_request_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('JitRequestDefinition', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('JitRequestDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/jitRequests/{jitRequestName}"} # type: ignore + + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + jit_request_name: str, + parameters: _models.JitRequestDefinition, + **kwargs: Any + ) -> AsyncLROPoller[_models.JitRequestDefinition]: + """Creates or updates the JIT request. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param jit_request_name: The name of the JIT request. + :type jit_request_name: str + :param parameters: Parameters supplied to the update JIT request. + :type parameters: ~azure.mgmt.managedapplication.v2018_06_01.models.JitRequestDefinition + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either JitRequestDefinition or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.managedapplication.v2018_06_01.models.JitRequestDefinition] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.JitRequestDefinition] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._create_or_update_initial( # type: ignore + resource_group_name=resource_group_name, + jit_request_name=jit_request_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('JitRequestDefinition', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/jitRequests/{jitRequestName}"} # type: ignore + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + jit_request_name: str, + parameters: _models.JitRequestPatchable, + **kwargs: Any + ) -> _models.JitRequestDefinition: + """Updates the JIT request. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param jit_request_name: The name of the JIT request. + :type jit_request_name: str + :param parameters: Parameters supplied to the update JIT request. + :type parameters: ~azure.mgmt.managedapplication.v2018_06_01.models.JitRequestPatchable + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JitRequestDefinition, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2018_06_01.models.JitRequestDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.JitRequestDefinition] + + _json = self._serialize.body(parameters, 'JitRequestPatchable') + + request = build_update_request( + resource_group_name=resource_group_name, + jit_request_name=jit_request_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('JitRequestDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/jitRequests/{jitRequestName}"} # type: ignore + + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + jit_request_name: str, + **kwargs: Any + ) -> None: + """Deletes the JIT request. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param jit_request_name: The name of the JIT request. + :type jit_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 + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_request( + resource_group_name=resource_group_name, + jit_request_name=jit_request_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/jitRequests/{jitRequestName}"} # type: ignore + + + @distributed_trace_async + async def list_by_subscription( + self, + **kwargs: Any + ) -> _models.JitRequestDefinitionListResult: + """Lists all JIT requests within the subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JitRequestDefinitionListResult, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2018_06_01.models.JitRequestDefinitionListResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.JitRequestDefinitionListResult] + + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('JitRequestDefinitionListResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Solutions/jitRequests"} # type: ignore + + + @distributed_trace_async + async def list_by_resource_group( + self, + resource_group_name: str, + **kwargs: Any + ) -> _models.JitRequestDefinitionListResult: + """Retrieves all JIT requests within the 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: JitRequestDefinitionListResult, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2018_06_01.models.JitRequestDefinitionListResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.JitRequestDefinitionListResult] + + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_resource_group.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('JitRequestDefinitionListResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/jitRequests"} # type: ignore + diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_06_01/aio/operations/_patch.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_06_01/aio/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_06_01/aio/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_06_01/models/__init__.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_06_01/models/__init__.py new file mode 100644 index 000000000000..868d7948eb45 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_06_01/models/__init__.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 ._models_py3 import Application +from ._models_py3 import ApplicationArtifact +from ._models_py3 import ApplicationAuthorization +from ._models_py3 import ApplicationBillingDetailsDefinition +from ._models_py3 import ApplicationClientDetails +from ._models_py3 import ApplicationDefinition +from ._models_py3 import ApplicationDefinitionArtifact +from ._models_py3 import ApplicationDefinitionListResult +from ._models_py3 import ApplicationDefinitionPatchable +from ._models_py3 import ApplicationJitAccessPolicy +from ._models_py3 import ApplicationListResult +from ._models_py3 import ApplicationNotificationEndpoint +from ._models_py3 import ApplicationNotificationPolicy +from ._models_py3 import ApplicationPackageContact +from ._models_py3 import ApplicationPackageLockingPolicyDefinition +from ._models_py3 import ApplicationPackageSupportUrls +from ._models_py3 import ApplicationPatchable +from ._models_py3 import ApplicationPolicy +from ._models_py3 import ApplicationPropertiesPatchable +from ._models_py3 import ErrorAdditionalInfo +from ._models_py3 import ErrorDetail +from ._models_py3 import ErrorResponse +from ._models_py3 import GenericResource +from ._models_py3 import Identity +from ._models_py3 import JitApproverDefinition +from ._models_py3 import JitAuthorizationPolicies +from ._models_py3 import JitRequestDefinition +from ._models_py3 import JitRequestDefinitionListResult +from ._models_py3 import JitRequestMetadata +from ._models_py3 import JitRequestPatchable +from ._models_py3 import JitSchedulingPolicy +from ._models_py3 import ListTokenRequest +from ._models_py3 import ManagedIdentityToken +from ._models_py3 import ManagedIdentityTokenResult +from ._models_py3 import Operation +from ._models_py3 import OperationAutoGenerated +from ._models_py3 import OperationDisplay +from ._models_py3 import OperationDisplayAutoGenerated +from ._models_py3 import OperationListResult +from ._models_py3 import Plan +from ._models_py3 import PlanPatchable +from ._models_py3 import Resource +from ._models_py3 import Sku +from ._models_py3 import UpdateAccessDefinition +from ._models_py3 import UserAssignedResourceIdentity + + +from ._application_client_enums import ( + ActionType, + ApplicationArtifactName, + ApplicationArtifactType, + ApplicationDefinitionArtifactName, + ApplicationLockLevel, + JitApprovalMode, + JitApproverType, + JitRequestState, + JitSchedulingType, + Origin, + ProvisioningState, + ResourceIdentityType, + Status, + Substatus, +) +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk +__all__ = [ + 'Application', + 'ApplicationArtifact', + 'ApplicationAuthorization', + 'ApplicationBillingDetailsDefinition', + 'ApplicationClientDetails', + 'ApplicationDefinition', + 'ApplicationDefinitionArtifact', + 'ApplicationDefinitionListResult', + 'ApplicationDefinitionPatchable', + 'ApplicationJitAccessPolicy', + 'ApplicationListResult', + 'ApplicationNotificationEndpoint', + 'ApplicationNotificationPolicy', + 'ApplicationPackageContact', + 'ApplicationPackageLockingPolicyDefinition', + 'ApplicationPackageSupportUrls', + 'ApplicationPatchable', + 'ApplicationPolicy', + 'ApplicationPropertiesPatchable', + 'ErrorAdditionalInfo', + 'ErrorDetail', + 'ErrorResponse', + 'GenericResource', + 'Identity', + 'JitApproverDefinition', + 'JitAuthorizationPolicies', + 'JitRequestDefinition', + 'JitRequestDefinitionListResult', + 'JitRequestMetadata', + 'JitRequestPatchable', + 'JitSchedulingPolicy', + 'ListTokenRequest', + 'ManagedIdentityToken', + 'ManagedIdentityTokenResult', + 'Operation', + 'OperationAutoGenerated', + 'OperationDisplay', + 'OperationDisplayAutoGenerated', + 'OperationListResult', + 'Plan', + 'PlanPatchable', + 'Resource', + 'Sku', + 'UpdateAccessDefinition', + 'UserAssignedResourceIdentity', + 'ActionType', + 'ApplicationArtifactName', + 'ApplicationArtifactType', + 'ApplicationDefinitionArtifactName', + 'ApplicationLockLevel', + 'JitApprovalMode', + 'JitApproverType', + 'JitRequestState', + 'JitSchedulingType', + 'Origin', + 'ProvisioningState', + 'ResourceIdentityType', + 'Status', + 'Substatus', +] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_06_01/models/_application_client_enums.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_06_01/models/_application_client_enums.py new file mode 100644 index 000000000000..cdab45e81a27 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_06_01/models/_application_client_enums.py @@ -0,0 +1,141 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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 azure.core import CaseInsensitiveEnumMeta + + +class ActionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. + """ + + INTERNAL = "Internal" + +class ApplicationArtifactName(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The managed application artifact name. + """ + + NOT_SPECIFIED = "NotSpecified" + VIEW_DEFINITION = "ViewDefinition" + AUTHORIZATIONS = "Authorizations" + CUSTOM_ROLE_DEFINITION = "CustomRoleDefinition" + +class ApplicationArtifactType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The managed application artifact type. + """ + + NOT_SPECIFIED = "NotSpecified" + TEMPLATE = "Template" + CUSTOM = "Custom" + +class ApplicationDefinitionArtifactName(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The managed application artifact name. + """ + + NOT_SPECIFIED = "NotSpecified" + APPLICATION_RESOURCE_TEMPLATE = "ApplicationResourceTemplate" + CREATE_UI_DEFINITION = "CreateUiDefinition" + MAIN_TEMPLATE_PARAMETERS = "MainTemplateParameters" + +class ApplicationLockLevel(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The managed application lock level. + """ + + CAN_NOT_DELETE = "CanNotDelete" + READ_ONLY = "ReadOnly" + NONE = "None" + +class JitApprovalMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The Jit approval mode. + """ + + NOT_SPECIFIED = "NotSpecified" + AUTO_APPROVE = "AutoApprove" + MANUAL_APPROVE = "ManualApprove" + +class JitApproverType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The approver type. + """ + + USER = "user" + GROUP = "group" + +class JitRequestState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The JIT request state. + """ + + NOT_SPECIFIED = "NotSpecified" + PENDING = "Pending" + APPROVED = "Approved" + DENIED = "Denied" + FAILED = "Failed" + CANCELED = "Canceled" + EXPIRED = "Expired" + TIMEOUT = "Timeout" + +class JitSchedulingType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The JIT request scheduling type. + """ + + NOT_SPECIFIED = "NotSpecified" + ONCE = "Once" + RECURRING = "Recurring" + +class Origin(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit + logs UX. Default value is "user,system" + """ + + USER = "user" + SYSTEM = "system" + USER_SYSTEM = "user,system" + +class ProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Provisioning status of the managed application. + """ + + NOT_SPECIFIED = "NotSpecified" + ACCEPTED = "Accepted" + RUNNING = "Running" + READY = "Ready" + CREATING = "Creating" + CREATED = "Created" + DELETING = "Deleting" + DELETED = "Deleted" + CANCELED = "Canceled" + FAILED = "Failed" + SUCCEEDED = "Succeeded" + UPDATING = "Updating" + +class ResourceIdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The identity type. + """ + + SYSTEM_ASSIGNED = "SystemAssigned" + USER_ASSIGNED = "UserAssigned" + SYSTEM_ASSIGNED_USER_ASSIGNED = "SystemAssigned, UserAssigned" + NONE = "None" + +class Status(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The JIT status. + """ + + NOT_SPECIFIED = "NotSpecified" + ELEVATE = "Elevate" + REMOVE = "Remove" + +class Substatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The sub status. + """ + + NOT_SPECIFIED = "NotSpecified" + APPROVED = "Approved" + DENIED = "Denied" + FAILED = "Failed" + EXPIRED = "Expired" + TIMEOUT = "Timeout" diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_06_01/models/_models_py3.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_06_01/models/_models_py3.py new file mode 100644 index 000000000000..88b73c2a0575 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_06_01/models/_models_py3.py @@ -0,0 +1,2394 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for 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 Any, Dict, List, Optional, TYPE_CHECKING, Union + +from azure.core.exceptions import HttpResponseError +import msrest.serialization + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + import __init__ as _models + + +class Resource(msrest.serialization.Model): + """Resource information. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Resource ID. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar location: Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'location': {'key': 'location', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + } + + def __init__( + self, + *, + location: Optional[str] = None, + tags: Optional[Dict[str, str]] = None, + **kwargs + ): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + """ + super(Resource, self).__init__(**kwargs) + self.id = None + self.name = None + self.type = None + self.location = location + self.tags = tags + + +class GenericResource(Resource): + """Resource information. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Resource ID. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar location: Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar managed_by: ID of the resource that manages this resource. + :vartype managed_by: str + :ivar sku: The SKU of the resource. + :vartype sku: ~azure.mgmt.managedapplication.v2018_06_01.models.Sku + """ + + _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'}, + 'location': {'key': 'location', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + 'managed_by': {'key': 'managedBy', 'type': 'str'}, + 'sku': {'key': 'sku', 'type': 'Sku'}, + } + + def __init__( + self, + *, + location: Optional[str] = None, + tags: Optional[Dict[str, str]] = None, + managed_by: Optional[str] = None, + sku: Optional["_models.Sku"] = None, + **kwargs + ): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword managed_by: ID of the resource that manages this resource. + :paramtype managed_by: str + :keyword sku: The SKU of the resource. + :paramtype sku: ~azure.mgmt.managedapplication.v2018_06_01.models.Sku + """ + super(GenericResource, self).__init__(location=location, tags=tags, **kwargs) + self.managed_by = managed_by + self.sku = sku + + +class Application(GenericResource): + """Information about managed application. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar id: Resource ID. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar location: Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar managed_by: ID of the resource that manages this resource. + :vartype managed_by: str + :ivar sku: The SKU of the resource. + :vartype sku: ~azure.mgmt.managedapplication.v2018_06_01.models.Sku + :ivar plan: The plan information. + :vartype plan: ~azure.mgmt.managedapplication.v2018_06_01.models.Plan + :ivar kind: Required. The kind of the managed application. Allowed values are MarketPlace and + ServiceCatalog. + :vartype kind: str + :ivar identity: The identity of the resource. + :vartype identity: ~azure.mgmt.managedapplication.v2018_06_01.models.Identity + :ivar managed_resource_group_id: The managed resource group Id. + :vartype managed_resource_group_id: str + :ivar application_definition_id: The fully qualified path of managed application definition Id. + :vartype application_definition_id: str + :ivar publisher_package_id: The publisher package Id. + :vartype publisher_package_id: str + :ivar parameters: Name and value pairs that define the managed application parameters. It can + be a JObject or a well formed JSON string. + :vartype parameters: any + :ivar outputs: Name and value pairs that define the managed application outputs. + :vartype outputs: any + :ivar provisioning_state: The managed application provisioning state. Known values are: + "NotSpecified", "Accepted", "Running", "Ready", "Creating", "Created", "Deleting", "Deleted", + "Canceled", "Failed", "Succeeded", "Updating". + :vartype provisioning_state: str or + ~azure.mgmt.managedapplication.v2018_06_01.models.ProvisioningState + :ivar billing_details: The managed application billing details. + :vartype billing_details: + ~azure.mgmt.managedapplication.v2018_06_01.models.ApplicationBillingDetailsDefinition + :ivar jit_access_policy: The managed application Jit access policy. + :vartype jit_access_policy: + ~azure.mgmt.managedapplication.v2018_06_01.models.ApplicationJitAccessPolicy + :ivar publisher_tenant_id: The publisher tenant Id. + :vartype publisher_tenant_id: str + :ivar authorizations: The read-only authorizations property that is retrieved from the + application package. + :vartype authorizations: + list[~azure.mgmt.managedapplication.v2018_06_01.models.ApplicationAuthorization] + :ivar customer_support: The read-only customer support property that is retrieved from the + application package. + :vartype customer_support: + ~azure.mgmt.managedapplication.v2018_06_01.models.ApplicationPackageContact + :ivar support_urls: The read-only support URLs property that is retrieved from the application + package. + :vartype support_urls: + ~azure.mgmt.managedapplication.v2018_06_01.models.ApplicationPackageSupportUrls + :ivar artifacts: The collection of managed application artifacts. + :vartype artifacts: list[~azure.mgmt.managedapplication.v2018_06_01.models.ApplicationArtifact] + :ivar created_by: The client entity that created the JIT request. + :vartype created_by: ~azure.mgmt.managedapplication.v2018_06_01.models.ApplicationClientDetails + :ivar updated_by: The client entity that last updated the JIT request. + :vartype updated_by: ~azure.mgmt.managedapplication.v2018_06_01.models.ApplicationClientDetails + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'kind': {'required': True, 'pattern': r'^[-\w\._,\(\)]+$'}, + 'outputs': {'readonly': True}, + 'provisioning_state': {'readonly': True}, + 'billing_details': {'readonly': True}, + 'publisher_tenant_id': {'readonly': True}, + 'authorizations': {'readonly': True}, + 'customer_support': {'readonly': True}, + 'support_urls': {'readonly': True}, + 'artifacts': {'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'}, + 'location': {'key': 'location', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + 'managed_by': {'key': 'managedBy', 'type': 'str'}, + 'sku': {'key': 'sku', 'type': 'Sku'}, + 'plan': {'key': 'plan', 'type': 'Plan'}, + 'kind': {'key': 'kind', 'type': 'str'}, + 'identity': {'key': 'identity', 'type': 'Identity'}, + 'managed_resource_group_id': {'key': 'properties.managedResourceGroupId', 'type': 'str'}, + 'application_definition_id': {'key': 'properties.applicationDefinitionId', 'type': 'str'}, + 'publisher_package_id': {'key': 'properties.publisherPackageId', 'type': 'str'}, + 'parameters': {'key': 'properties.parameters', 'type': 'object'}, + 'outputs': {'key': 'properties.outputs', 'type': 'object'}, + 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + 'billing_details': {'key': 'properties.billingDetails', 'type': 'ApplicationBillingDetailsDefinition'}, + 'jit_access_policy': {'key': 'properties.jitAccessPolicy', 'type': 'ApplicationJitAccessPolicy'}, + 'publisher_tenant_id': {'key': 'properties.publisherTenantId', 'type': 'str'}, + 'authorizations': {'key': 'properties.authorizations', 'type': '[ApplicationAuthorization]'}, + 'customer_support': {'key': 'properties.customerSupport', 'type': 'ApplicationPackageContact'}, + 'support_urls': {'key': 'properties.supportUrls', 'type': 'ApplicationPackageSupportUrls'}, + 'artifacts': {'key': 'properties.artifacts', 'type': '[ApplicationArtifact]'}, + 'created_by': {'key': 'properties.createdBy', 'type': 'ApplicationClientDetails'}, + 'updated_by': {'key': 'properties.updatedBy', 'type': 'ApplicationClientDetails'}, + } + + def __init__( + self, + *, + kind: str, + location: Optional[str] = None, + tags: Optional[Dict[str, str]] = None, + managed_by: Optional[str] = None, + sku: Optional["_models.Sku"] = None, + plan: Optional["_models.Plan"] = None, + identity: Optional["_models.Identity"] = None, + managed_resource_group_id: Optional[str] = None, + application_definition_id: Optional[str] = None, + publisher_package_id: Optional[str] = None, + parameters: Optional[Any] = None, + jit_access_policy: Optional["_models.ApplicationJitAccessPolicy"] = None, + **kwargs + ): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword managed_by: ID of the resource that manages this resource. + :paramtype managed_by: str + :keyword sku: The SKU of the resource. + :paramtype sku: ~azure.mgmt.managedapplication.v2018_06_01.models.Sku + :keyword plan: The plan information. + :paramtype plan: ~azure.mgmt.managedapplication.v2018_06_01.models.Plan + :keyword kind: Required. The kind of the managed application. Allowed values are MarketPlace + and ServiceCatalog. + :paramtype kind: str + :keyword identity: The identity of the resource. + :paramtype identity: ~azure.mgmt.managedapplication.v2018_06_01.models.Identity + :keyword managed_resource_group_id: The managed resource group Id. + :paramtype managed_resource_group_id: str + :keyword application_definition_id: The fully qualified path of managed application definition + Id. + :paramtype application_definition_id: str + :keyword publisher_package_id: The publisher package Id. + :paramtype publisher_package_id: str + :keyword parameters: Name and value pairs that define the managed application parameters. It + can be a JObject or a well formed JSON string. + :paramtype parameters: any + :keyword jit_access_policy: The managed application Jit access policy. + :paramtype jit_access_policy: + ~azure.mgmt.managedapplication.v2018_06_01.models.ApplicationJitAccessPolicy + """ + super(Application, self).__init__(location=location, tags=tags, managed_by=managed_by, sku=sku, **kwargs) + self.plan = plan + self.kind = kind + self.identity = identity + self.managed_resource_group_id = managed_resource_group_id + self.application_definition_id = application_definition_id + self.publisher_package_id = publisher_package_id + self.parameters = parameters + self.outputs = None + self.provisioning_state = None + self.billing_details = None + self.jit_access_policy = jit_access_policy + self.publisher_tenant_id = None + self.authorizations = None + self.customer_support = None + self.support_urls = None + self.artifacts = None + self.created_by = None + self.updated_by = None + + +class ApplicationArtifact(msrest.serialization.Model): + """Managed application artifact. + + All required parameters must be populated in order to send to Azure. + + :ivar name: Required. The managed application artifact name. Known values are: "NotSpecified", + "ViewDefinition", "Authorizations", "CustomRoleDefinition". + :vartype name: str or ~azure.mgmt.managedapplication.v2018_06_01.models.ApplicationArtifactName + :ivar uri: Required. The managed application artifact blob uri. + :vartype uri: str + :ivar type: Required. The managed application artifact type. Known values are: "NotSpecified", + "Template", "Custom". + :vartype type: str or ~azure.mgmt.managedapplication.v2018_06_01.models.ApplicationArtifactType + """ + + _validation = { + 'name': {'required': True}, + 'uri': {'required': True}, + 'type': {'required': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'uri': {'key': 'uri', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + } + + def __init__( + self, + *, + name: Union[str, "_models.ApplicationArtifactName"], + uri: str, + type: Union[str, "_models.ApplicationArtifactType"], + **kwargs + ): + """ + :keyword name: Required. The managed application artifact name. Known values are: + "NotSpecified", "ViewDefinition", "Authorizations", "CustomRoleDefinition". + :paramtype name: str or + ~azure.mgmt.managedapplication.v2018_06_01.models.ApplicationArtifactName + :keyword uri: Required. The managed application artifact blob uri. + :paramtype uri: str + :keyword type: Required. The managed application artifact type. Known values are: + "NotSpecified", "Template", "Custom". + :paramtype type: str or + ~azure.mgmt.managedapplication.v2018_06_01.models.ApplicationArtifactType + """ + super(ApplicationArtifact, self).__init__(**kwargs) + self.name = name + self.uri = uri + self.type = type + + +class ApplicationAuthorization(msrest.serialization.Model): + """The managed application provider authorization. + + All required parameters must be populated in order to send to Azure. + + :ivar principal_id: Required. The provider's principal identifier. This is the identity that + the provider will use to call ARM to manage the managed application resources. + :vartype principal_id: str + :ivar role_definition_id: Required. The provider's role definition identifier. This role will + define all the permissions that the provider must have on the managed application's container + resource group. This role definition cannot have permission to delete the resource group. + :vartype role_definition_id: str + """ + + _validation = { + 'principal_id': {'required': True}, + 'role_definition_id': {'required': True}, + } + + _attribute_map = { + 'principal_id': {'key': 'principalId', 'type': 'str'}, + 'role_definition_id': {'key': 'roleDefinitionId', 'type': 'str'}, + } + + def __init__( + self, + *, + principal_id: str, + role_definition_id: str, + **kwargs + ): + """ + :keyword principal_id: Required. The provider's principal identifier. This is the identity that + the provider will use to call ARM to manage the managed application resources. + :paramtype principal_id: str + :keyword role_definition_id: Required. The provider's role definition identifier. This role + will define all the permissions that the provider must have on the managed application's + container resource group. This role definition cannot have permission to delete the resource + group. + :paramtype role_definition_id: str + """ + super(ApplicationAuthorization, self).__init__(**kwargs) + self.principal_id = principal_id + self.role_definition_id = role_definition_id + + +class ApplicationBillingDetailsDefinition(msrest.serialization.Model): + """Managed application billing details definition. + + :ivar resource_usage_id: The managed application resource usage Id. + :vartype resource_usage_id: str + """ + + _attribute_map = { + 'resource_usage_id': {'key': 'resourceUsageId', 'type': 'str'}, + } + + def __init__( + self, + *, + resource_usage_id: Optional[str] = None, + **kwargs + ): + """ + :keyword resource_usage_id: The managed application resource usage Id. + :paramtype resource_usage_id: str + """ + super(ApplicationBillingDetailsDefinition, self).__init__(**kwargs) + self.resource_usage_id = resource_usage_id + + +class ApplicationClientDetails(msrest.serialization.Model): + """The application client details to track the entity creating/updating the managed app resource. + + :ivar oid: The client Oid. + :vartype oid: str + :ivar puid: The client Puid. + :vartype puid: str + :ivar application_id: The client application Id. + :vartype application_id: str + """ + + _attribute_map = { + 'oid': {'key': 'oid', 'type': 'str'}, + 'puid': {'key': 'puid', 'type': 'str'}, + 'application_id': {'key': 'applicationId', 'type': 'str'}, + } + + def __init__( + self, + *, + oid: Optional[str] = None, + puid: Optional[str] = None, + application_id: Optional[str] = None, + **kwargs + ): + """ + :keyword oid: The client Oid. + :paramtype oid: str + :keyword puid: The client Puid. + :paramtype puid: str + :keyword application_id: The client application Id. + :paramtype application_id: str + """ + super(ApplicationClientDetails, self).__init__(**kwargs) + self.oid = oid + self.puid = puid + self.application_id = application_id + + +class ApplicationDefinition(GenericResource): + """Information about managed application definition. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar id: Resource ID. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar location: Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar managed_by: ID of the resource that manages this resource. + :vartype managed_by: str + :ivar sku: The SKU of the resource. + :vartype sku: ~azure.mgmt.managedapplication.v2018_06_01.models.Sku + :ivar lock_level: Required. The managed application lock level. Known values are: + "CanNotDelete", "ReadOnly", "None". + :vartype lock_level: str or + ~azure.mgmt.managedapplication.v2018_06_01.models.ApplicationLockLevel + :ivar display_name: The managed application definition display name. + :vartype display_name: str + :ivar is_enabled: A value indicating whether the package is enabled or not. + :vartype is_enabled: bool + :ivar authorizations: The managed application provider authorizations. + :vartype authorizations: + list[~azure.mgmt.managedapplication.v2018_06_01.models.ApplicationAuthorization] + :ivar artifacts: The collection of managed application artifacts. The portal will use the files + specified as artifacts to construct the user experience of creating a managed application from + a managed application definition. + :vartype artifacts: + list[~azure.mgmt.managedapplication.v2018_06_01.models.ApplicationDefinitionArtifact] + :ivar description: The managed application definition description. + :vartype description: str + :ivar package_file_uri: The managed application definition package file Uri. Use this element. + :vartype package_file_uri: str + :ivar main_template: The inline main template json which has resources to be provisioned. It + can be a JObject or well-formed JSON string. + :vartype main_template: any + :ivar create_ui_definition: The createUiDefinition json for the backing template with + Microsoft.Solutions/applications resource. It can be a JObject or well-formed JSON string. + :vartype create_ui_definition: any + :ivar policies: The managed application provider policies. + :vartype policies: list[~azure.mgmt.managedapplication.v2018_06_01.models.ApplicationPolicy] + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'lock_level': {'required': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'location': {'key': 'location', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + 'managed_by': {'key': 'managedBy', 'type': 'str'}, + 'sku': {'key': 'sku', 'type': 'Sku'}, + 'lock_level': {'key': 'properties.lockLevel', 'type': 'str'}, + 'display_name': {'key': 'properties.displayName', 'type': 'str'}, + 'is_enabled': {'key': 'properties.isEnabled', 'type': 'bool'}, + 'authorizations': {'key': 'properties.authorizations', 'type': '[ApplicationAuthorization]'}, + 'artifacts': {'key': 'properties.artifacts', 'type': '[ApplicationDefinitionArtifact]'}, + 'description': {'key': 'properties.description', 'type': 'str'}, + 'package_file_uri': {'key': 'properties.packageFileUri', 'type': 'str'}, + 'main_template': {'key': 'properties.mainTemplate', 'type': 'object'}, + 'create_ui_definition': {'key': 'properties.createUiDefinition', 'type': 'object'}, + 'policies': {'key': 'properties.policies', 'type': '[ApplicationPolicy]'}, + } + + def __init__( + self, + *, + lock_level: Union[str, "_models.ApplicationLockLevel"], + location: Optional[str] = None, + tags: Optional[Dict[str, str]] = None, + managed_by: Optional[str] = None, + sku: Optional["_models.Sku"] = None, + display_name: Optional[str] = None, + is_enabled: Optional[bool] = None, + authorizations: Optional[List["_models.ApplicationAuthorization"]] = None, + artifacts: Optional[List["_models.ApplicationDefinitionArtifact"]] = None, + description: Optional[str] = None, + package_file_uri: Optional[str] = None, + main_template: Optional[Any] = None, + create_ui_definition: Optional[Any] = None, + policies: Optional[List["_models.ApplicationPolicy"]] = None, + **kwargs + ): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword managed_by: ID of the resource that manages this resource. + :paramtype managed_by: str + :keyword sku: The SKU of the resource. + :paramtype sku: ~azure.mgmt.managedapplication.v2018_06_01.models.Sku + :keyword lock_level: Required. The managed application lock level. Known values are: + "CanNotDelete", "ReadOnly", "None". + :paramtype lock_level: str or + ~azure.mgmt.managedapplication.v2018_06_01.models.ApplicationLockLevel + :keyword display_name: The managed application definition display name. + :paramtype display_name: str + :keyword is_enabled: A value indicating whether the package is enabled or not. + :paramtype is_enabled: bool + :keyword authorizations: The managed application provider authorizations. + :paramtype authorizations: + list[~azure.mgmt.managedapplication.v2018_06_01.models.ApplicationAuthorization] + :keyword artifacts: The collection of managed application artifacts. The portal will use the + files specified as artifacts to construct the user experience of creating a managed application + from a managed application definition. + :paramtype artifacts: + list[~azure.mgmt.managedapplication.v2018_06_01.models.ApplicationDefinitionArtifact] + :keyword description: The managed application definition description. + :paramtype description: str + :keyword package_file_uri: The managed application definition package file Uri. Use this + element. + :paramtype package_file_uri: str + :keyword main_template: The inline main template json which has resources to be provisioned. It + can be a JObject or well-formed JSON string. + :paramtype main_template: any + :keyword create_ui_definition: The createUiDefinition json for the backing template with + Microsoft.Solutions/applications resource. It can be a JObject or well-formed JSON string. + :paramtype create_ui_definition: any + :keyword policies: The managed application provider policies. + :paramtype policies: list[~azure.mgmt.managedapplication.v2018_06_01.models.ApplicationPolicy] + """ + super(ApplicationDefinition, self).__init__(location=location, tags=tags, managed_by=managed_by, sku=sku, **kwargs) + self.lock_level = lock_level + self.display_name = display_name + self.is_enabled = is_enabled + self.authorizations = authorizations + self.artifacts = artifacts + self.description = description + self.package_file_uri = package_file_uri + self.main_template = main_template + self.create_ui_definition = create_ui_definition + self.policies = policies + + +class ApplicationDefinitionArtifact(msrest.serialization.Model): + """Application definition artifact. + + All required parameters must be populated in order to send to Azure. + + :ivar name: Required. The managed application definition artifact name. Known values are: + "NotSpecified", "ApplicationResourceTemplate", "CreateUiDefinition", "MainTemplateParameters". + :vartype name: str or + ~azure.mgmt.managedapplication.v2018_06_01.models.ApplicationDefinitionArtifactName + :ivar uri: Required. The managed application definition artifact blob uri. + :vartype uri: str + :ivar type: Required. The managed application definition artifact type. Known values are: + "NotSpecified", "Template", "Custom". + :vartype type: str or ~azure.mgmt.managedapplication.v2018_06_01.models.ApplicationArtifactType + """ + + _validation = { + 'name': {'required': True}, + 'uri': {'required': True}, + 'type': {'required': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'uri': {'key': 'uri', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + } + + def __init__( + self, + *, + name: Union[str, "_models.ApplicationDefinitionArtifactName"], + uri: str, + type: Union[str, "_models.ApplicationArtifactType"], + **kwargs + ): + """ + :keyword name: Required. The managed application definition artifact name. Known values are: + "NotSpecified", "ApplicationResourceTemplate", "CreateUiDefinition", "MainTemplateParameters". + :paramtype name: str or + ~azure.mgmt.managedapplication.v2018_06_01.models.ApplicationDefinitionArtifactName + :keyword uri: Required. The managed application definition artifact blob uri. + :paramtype uri: str + :keyword type: Required. The managed application definition artifact type. Known values are: + "NotSpecified", "Template", "Custom". + :paramtype type: str or + ~azure.mgmt.managedapplication.v2018_06_01.models.ApplicationArtifactType + """ + super(ApplicationDefinitionArtifact, self).__init__(**kwargs) + self.name = name + self.uri = uri + self.type = type + + +class ApplicationDefinitionListResult(msrest.serialization.Model): + """List of managed application definitions. + + :ivar value: The array of managed application definitions. + :vartype value: list[~azure.mgmt.managedapplication.v2018_06_01.models.ApplicationDefinition] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[ApplicationDefinition]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["_models.ApplicationDefinition"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + """ + :keyword value: The array of managed application definitions. + :paramtype value: list[~azure.mgmt.managedapplication.v2018_06_01.models.ApplicationDefinition] + :keyword next_link: The URL to use for getting the next set of results. + :paramtype next_link: str + """ + super(ApplicationDefinitionListResult, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class ApplicationDefinitionPatchable(msrest.serialization.Model): + """Information about an application definition request. + + :ivar tags: A set of tags. Application definition tags. + :vartype tags: dict[str, str] + """ + + _attribute_map = { + 'tags': {'key': 'tags', 'type': '{str}'}, + } + + def __init__( + self, + *, + tags: Optional[Dict[str, str]] = None, + **kwargs + ): + """ + :keyword tags: A set of tags. Application definition tags. + :paramtype tags: dict[str, str] + """ + super(ApplicationDefinitionPatchable, self).__init__(**kwargs) + self.tags = tags + + +class ApplicationJitAccessPolicy(msrest.serialization.Model): + """Managed application Jit access policy. + + All required parameters must be populated in order to send to Azure. + + :ivar jit_access_enabled: Required. Whether the JIT access is enabled. + :vartype jit_access_enabled: bool + :ivar jit_approval_mode: JIT approval mode. Known values are: "NotSpecified", "AutoApprove", + "ManualApprove". + :vartype jit_approval_mode: str or + ~azure.mgmt.managedapplication.v2018_06_01.models.JitApprovalMode + :ivar jit_approvers: The JIT approvers. + :vartype jit_approvers: + list[~azure.mgmt.managedapplication.v2018_06_01.models.JitApproverDefinition] + :ivar maximum_jit_access_duration: The maximum duration JIT access is granted. This is an + ISO8601 time period value. + :vartype maximum_jit_access_duration: str + """ + + _validation = { + 'jit_access_enabled': {'required': True}, + } + + _attribute_map = { + 'jit_access_enabled': {'key': 'jitAccessEnabled', 'type': 'bool'}, + 'jit_approval_mode': {'key': 'jitApprovalMode', 'type': 'str'}, + 'jit_approvers': {'key': 'jitApprovers', 'type': '[JitApproverDefinition]'}, + 'maximum_jit_access_duration': {'key': 'maximumJitAccessDuration', 'type': 'str'}, + } + + def __init__( + self, + *, + jit_access_enabled: bool, + jit_approval_mode: Optional[Union[str, "_models.JitApprovalMode"]] = None, + jit_approvers: Optional[List["_models.JitApproverDefinition"]] = None, + maximum_jit_access_duration: Optional[str] = None, + **kwargs + ): + """ + :keyword jit_access_enabled: Required. Whether the JIT access is enabled. + :paramtype jit_access_enabled: bool + :keyword jit_approval_mode: JIT approval mode. Known values are: "NotSpecified", "AutoApprove", + "ManualApprove". + :paramtype jit_approval_mode: str or + ~azure.mgmt.managedapplication.v2018_06_01.models.JitApprovalMode + :keyword jit_approvers: The JIT approvers. + :paramtype jit_approvers: + list[~azure.mgmt.managedapplication.v2018_06_01.models.JitApproverDefinition] + :keyword maximum_jit_access_duration: The maximum duration JIT access is granted. This is an + ISO8601 time period value. + :paramtype maximum_jit_access_duration: str + """ + super(ApplicationJitAccessPolicy, self).__init__(**kwargs) + self.jit_access_enabled = jit_access_enabled + self.jit_approval_mode = jit_approval_mode + self.jit_approvers = jit_approvers + self.maximum_jit_access_duration = maximum_jit_access_duration + + +class ApplicationListResult(msrest.serialization.Model): + """List of managed applications. + + :ivar value: The array of managed applications. + :vartype value: list[~azure.mgmt.managedapplication.v2018_06_01.models.Application] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Application]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["_models.Application"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + """ + :keyword value: The array of managed applications. + :paramtype value: list[~azure.mgmt.managedapplication.v2018_06_01.models.Application] + :keyword next_link: The URL to use for getting the next set of results. + :paramtype next_link: str + """ + super(ApplicationListResult, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class ApplicationNotificationEndpoint(msrest.serialization.Model): + """Managed application notification endpoint. + + All required parameters must be populated in order to send to Azure. + + :ivar uri: Required. The managed application notification endpoint uri. + :vartype uri: str + """ + + _validation = { + 'uri': {'required': True}, + } + + _attribute_map = { + 'uri': {'key': 'uri', 'type': 'str'}, + } + + def __init__( + self, + *, + uri: str, + **kwargs + ): + """ + :keyword uri: Required. The managed application notification endpoint uri. + :paramtype uri: str + """ + super(ApplicationNotificationEndpoint, self).__init__(**kwargs) + self.uri = uri + + +class ApplicationNotificationPolicy(msrest.serialization.Model): + """Managed application notification policy. + + All required parameters must be populated in order to send to Azure. + + :ivar notification_endpoints: Required. The managed application notification endpoint. + :vartype notification_endpoints: + list[~azure.mgmt.managedapplication.v2018_06_01.models.ApplicationNotificationEndpoint] + """ + + _validation = { + 'notification_endpoints': {'required': True}, + } + + _attribute_map = { + 'notification_endpoints': {'key': 'notificationEndpoints', 'type': '[ApplicationNotificationEndpoint]'}, + } + + def __init__( + self, + *, + notification_endpoints: List["_models.ApplicationNotificationEndpoint"], + **kwargs + ): + """ + :keyword notification_endpoints: Required. The managed application notification endpoint. + :paramtype notification_endpoints: + list[~azure.mgmt.managedapplication.v2018_06_01.models.ApplicationNotificationEndpoint] + """ + super(ApplicationNotificationPolicy, self).__init__(**kwargs) + self.notification_endpoints = notification_endpoints + + +class ApplicationPackageContact(msrest.serialization.Model): + """The application package contact information. + + All required parameters must be populated in order to send to Azure. + + :ivar contact_name: The contact name. + :vartype contact_name: str + :ivar email: Required. The contact email. + :vartype email: str + :ivar phone: Required. The contact phone number. + :vartype phone: str + """ + + _validation = { + 'email': {'required': True}, + 'phone': {'required': True}, + } + + _attribute_map = { + 'contact_name': {'key': 'contactName', 'type': 'str'}, + 'email': {'key': 'email', 'type': 'str'}, + 'phone': {'key': 'phone', 'type': 'str'}, + } + + def __init__( + self, + *, + email: str, + phone: str, + contact_name: Optional[str] = None, + **kwargs + ): + """ + :keyword contact_name: The contact name. + :paramtype contact_name: str + :keyword email: Required. The contact email. + :paramtype email: str + :keyword phone: Required. The contact phone number. + :paramtype phone: str + """ + super(ApplicationPackageContact, self).__init__(**kwargs) + self.contact_name = contact_name + self.email = email + self.phone = phone + + +class ApplicationPackageLockingPolicyDefinition(msrest.serialization.Model): + """Managed application locking policy. + + :ivar allowed_actions: The deny assignment excluded actions. + :vartype allowed_actions: list[str] + :ivar allowed_data_actions: The deny assignment excluded data actions. + :vartype allowed_data_actions: list[str] + """ + + _attribute_map = { + 'allowed_actions': {'key': 'allowedActions', 'type': '[str]'}, + 'allowed_data_actions': {'key': 'allowedDataActions', 'type': '[str]'}, + } + + def __init__( + self, + *, + allowed_actions: Optional[List[str]] = None, + allowed_data_actions: Optional[List[str]] = None, + **kwargs + ): + """ + :keyword allowed_actions: The deny assignment excluded actions. + :paramtype allowed_actions: list[str] + :keyword allowed_data_actions: The deny assignment excluded data actions. + :paramtype allowed_data_actions: list[str] + """ + super(ApplicationPackageLockingPolicyDefinition, self).__init__(**kwargs) + self.allowed_actions = allowed_actions + self.allowed_data_actions = allowed_data_actions + + +class ApplicationPackageSupportUrls(msrest.serialization.Model): + """The appliance package support URLs. + + :ivar public_azure: The public azure support URL. + :vartype public_azure: str + :ivar government_cloud: The government cloud support URL. + :vartype government_cloud: str + """ + + _attribute_map = { + 'public_azure': {'key': 'publicAzure', 'type': 'str'}, + 'government_cloud': {'key': 'governmentCloud', 'type': 'str'}, + } + + def __init__( + self, + *, + public_azure: Optional[str] = None, + government_cloud: Optional[str] = None, + **kwargs + ): + """ + :keyword public_azure: The public azure support URL. + :paramtype public_azure: str + :keyword government_cloud: The government cloud support URL. + :paramtype government_cloud: str + """ + super(ApplicationPackageSupportUrls, self).__init__(**kwargs) + self.public_azure = public_azure + self.government_cloud = government_cloud + + +class ApplicationPatchable(GenericResource): + """Information about managed application. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Resource ID. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar location: Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar managed_by: ID of the resource that manages this resource. + :vartype managed_by: str + :ivar sku: The SKU of the resource. + :vartype sku: ~azure.mgmt.managedapplication.v2018_06_01.models.Sku + :ivar plan: The plan information. + :vartype plan: ~azure.mgmt.managedapplication.v2018_06_01.models.PlanPatchable + :ivar kind: The kind of the managed application. Allowed values are MarketPlace and + ServiceCatalog. + :vartype kind: str + :ivar identity: The identity of the resource. + :vartype identity: ~azure.mgmt.managedapplication.v2018_06_01.models.Identity + :ivar managed_resource_group_id: The managed resource group Id. + :vartype managed_resource_group_id: str + :ivar application_definition_id: The fully qualified path of managed application definition Id. + :vartype application_definition_id: str + :ivar publisher_package_id: The publisher package Id. + :vartype publisher_package_id: str + :ivar parameters: Name and value pairs that define the managed application parameters. It can + be a JObject or a well formed JSON string. + :vartype parameters: any + :ivar outputs: Name and value pairs that define the managed application outputs. + :vartype outputs: any + :ivar provisioning_state: The managed application provisioning state. Known values are: + "NotSpecified", "Accepted", "Running", "Ready", "Creating", "Created", "Deleting", "Deleted", + "Canceled", "Failed", "Succeeded", "Updating". + :vartype provisioning_state: str or + ~azure.mgmt.managedapplication.v2018_06_01.models.ProvisioningState + :ivar billing_details: The managed application billing details. + :vartype billing_details: + ~azure.mgmt.managedapplication.v2018_06_01.models.ApplicationBillingDetailsDefinition + :ivar jit_access_policy: The managed application Jit access policy. + :vartype jit_access_policy: + ~azure.mgmt.managedapplication.v2018_06_01.models.ApplicationJitAccessPolicy + :ivar publisher_tenant_id: The publisher tenant Id. + :vartype publisher_tenant_id: str + :ivar authorizations: The read-only authorizations property that is retrieved from the + application package. + :vartype authorizations: + list[~azure.mgmt.managedapplication.v2018_06_01.models.ApplicationAuthorization] + :ivar customer_support: The read-only customer support property that is retrieved from the + application package. + :vartype customer_support: + ~azure.mgmt.managedapplication.v2018_06_01.models.ApplicationPackageContact + :ivar support_urls: The read-only support URLs property that is retrieved from the application + package. + :vartype support_urls: + ~azure.mgmt.managedapplication.v2018_06_01.models.ApplicationPackageSupportUrls + :ivar artifacts: The collection of managed application artifacts. + :vartype artifacts: list[~azure.mgmt.managedapplication.v2018_06_01.models.ApplicationArtifact] + :ivar created_by: The client entity that created the JIT request. + :vartype created_by: ~azure.mgmt.managedapplication.v2018_06_01.models.ApplicationClientDetails + :ivar updated_by: The client entity that last updated the JIT request. + :vartype updated_by: ~azure.mgmt.managedapplication.v2018_06_01.models.ApplicationClientDetails + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'kind': {'pattern': r'^[-\w\._,\(\)]+$'}, + 'outputs': {'readonly': True}, + 'provisioning_state': {'readonly': True}, + 'billing_details': {'readonly': True}, + 'publisher_tenant_id': {'readonly': True}, + 'authorizations': {'readonly': True}, + 'customer_support': {'readonly': True}, + 'support_urls': {'readonly': True}, + 'artifacts': {'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'}, + 'location': {'key': 'location', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + 'managed_by': {'key': 'managedBy', 'type': 'str'}, + 'sku': {'key': 'sku', 'type': 'Sku'}, + 'plan': {'key': 'plan', 'type': 'PlanPatchable'}, + 'kind': {'key': 'kind', 'type': 'str'}, + 'identity': {'key': 'identity', 'type': 'Identity'}, + 'managed_resource_group_id': {'key': 'properties.managedResourceGroupId', 'type': 'str'}, + 'application_definition_id': {'key': 'properties.applicationDefinitionId', 'type': 'str'}, + 'publisher_package_id': {'key': 'properties.publisherPackageId', 'type': 'str'}, + 'parameters': {'key': 'properties.parameters', 'type': 'object'}, + 'outputs': {'key': 'properties.outputs', 'type': 'object'}, + 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + 'billing_details': {'key': 'properties.billingDetails', 'type': 'ApplicationBillingDetailsDefinition'}, + 'jit_access_policy': {'key': 'properties.jitAccessPolicy', 'type': 'ApplicationJitAccessPolicy'}, + 'publisher_tenant_id': {'key': 'properties.publisherTenantId', 'type': 'str'}, + 'authorizations': {'key': 'properties.authorizations', 'type': '[ApplicationAuthorization]'}, + 'customer_support': {'key': 'properties.customerSupport', 'type': 'ApplicationPackageContact'}, + 'support_urls': {'key': 'properties.supportUrls', 'type': 'ApplicationPackageSupportUrls'}, + 'artifacts': {'key': 'properties.artifacts', 'type': '[ApplicationArtifact]'}, + 'created_by': {'key': 'properties.createdBy', 'type': 'ApplicationClientDetails'}, + 'updated_by': {'key': 'properties.updatedBy', 'type': 'ApplicationClientDetails'}, + } + + def __init__( + self, + *, + location: Optional[str] = None, + tags: Optional[Dict[str, str]] = None, + managed_by: Optional[str] = None, + sku: Optional["_models.Sku"] = None, + plan: Optional["_models.PlanPatchable"] = None, + kind: Optional[str] = None, + identity: Optional["_models.Identity"] = None, + managed_resource_group_id: Optional[str] = None, + application_definition_id: Optional[str] = None, + publisher_package_id: Optional[str] = None, + parameters: Optional[Any] = None, + jit_access_policy: Optional["_models.ApplicationJitAccessPolicy"] = None, + **kwargs + ): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword managed_by: ID of the resource that manages this resource. + :paramtype managed_by: str + :keyword sku: The SKU of the resource. + :paramtype sku: ~azure.mgmt.managedapplication.v2018_06_01.models.Sku + :keyword plan: The plan information. + :paramtype plan: ~azure.mgmt.managedapplication.v2018_06_01.models.PlanPatchable + :keyword kind: The kind of the managed application. Allowed values are MarketPlace and + ServiceCatalog. + :paramtype kind: str + :keyword identity: The identity of the resource. + :paramtype identity: ~azure.mgmt.managedapplication.v2018_06_01.models.Identity + :keyword managed_resource_group_id: The managed resource group Id. + :paramtype managed_resource_group_id: str + :keyword application_definition_id: The fully qualified path of managed application definition + Id. + :paramtype application_definition_id: str + :keyword publisher_package_id: The publisher package Id. + :paramtype publisher_package_id: str + :keyword parameters: Name and value pairs that define the managed application parameters. It + can be a JObject or a well formed JSON string. + :paramtype parameters: any + :keyword jit_access_policy: The managed application Jit access policy. + :paramtype jit_access_policy: + ~azure.mgmt.managedapplication.v2018_06_01.models.ApplicationJitAccessPolicy + """ + super(ApplicationPatchable, self).__init__(location=location, tags=tags, managed_by=managed_by, sku=sku, **kwargs) + self.plan = plan + self.kind = kind + self.identity = identity + self.managed_resource_group_id = managed_resource_group_id + self.application_definition_id = application_definition_id + self.publisher_package_id = publisher_package_id + self.parameters = parameters + self.outputs = None + self.provisioning_state = None + self.billing_details = None + self.jit_access_policy = jit_access_policy + self.publisher_tenant_id = None + self.authorizations = None + self.customer_support = None + self.support_urls = None + self.artifacts = None + self.created_by = None + self.updated_by = None + + +class ApplicationPolicy(msrest.serialization.Model): + """Managed application policy. + + :ivar name: The policy name. + :vartype name: str + :ivar policy_definition_id: The policy definition Id. + :vartype policy_definition_id: str + :ivar parameters: The policy parameters. + :vartype parameters: str + """ + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'policy_definition_id': {'key': 'policyDefinitionId', 'type': 'str'}, + 'parameters': {'key': 'parameters', 'type': 'str'}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + policy_definition_id: Optional[str] = None, + parameters: Optional[str] = None, + **kwargs + ): + """ + :keyword name: The policy name. + :paramtype name: str + :keyword policy_definition_id: The policy definition Id. + :paramtype policy_definition_id: str + :keyword parameters: The policy parameters. + :paramtype parameters: str + """ + super(ApplicationPolicy, self).__init__(**kwargs) + self.name = name + self.policy_definition_id = policy_definition_id + self.parameters = parameters + + +class ApplicationPropertiesPatchable(msrest.serialization.Model): + """The managed application properties. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar managed_resource_group_id: The managed resource group Id. + :vartype managed_resource_group_id: str + :ivar application_definition_id: The fully qualified path of managed application definition Id. + :vartype application_definition_id: str + :ivar parameters: Name and value pairs that define the managed application parameters. It can + be a JObject or a well formed JSON string. + :vartype parameters: any + :ivar outputs: Name and value pairs that define the managed application outputs. + :vartype outputs: any + :ivar provisioning_state: The managed application provisioning state. Known values are: + "NotSpecified", "Accepted", "Running", "Ready", "Creating", "Created", "Deleting", "Deleted", + "Canceled", "Failed", "Succeeded", "Updating". + :vartype provisioning_state: str or + ~azure.mgmt.managedapplication.v2018_06_01.models.ProvisioningState + """ + + _validation = { + 'outputs': {'readonly': True}, + 'provisioning_state': {'readonly': True}, + } + + _attribute_map = { + 'managed_resource_group_id': {'key': 'managedResourceGroupId', 'type': 'str'}, + 'application_definition_id': {'key': 'applicationDefinitionId', 'type': 'str'}, + 'parameters': {'key': 'parameters', 'type': 'object'}, + 'outputs': {'key': 'outputs', 'type': 'object'}, + 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, + } + + def __init__( + self, + *, + managed_resource_group_id: Optional[str] = None, + application_definition_id: Optional[str] = None, + parameters: Optional[Any] = None, + **kwargs + ): + """ + :keyword managed_resource_group_id: The managed resource group Id. + :paramtype managed_resource_group_id: str + :keyword application_definition_id: The fully qualified path of managed application definition + Id. + :paramtype application_definition_id: str + :keyword parameters: Name and value pairs that define the managed application parameters. It + can be a JObject or a well formed JSON string. + :paramtype parameters: any + """ + super(ApplicationPropertiesPatchable, self).__init__(**kwargs) + self.managed_resource_group_id = managed_resource_group_id + self.application_definition_id = application_definition_id + self.parameters = parameters + self.outputs = None + self.provisioning_state = None + + +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.managedapplication.v2018_06_01.models.ErrorDetail] + :ivar additional_info: The error additional info. + :vartype additional_info: + list[~azure.mgmt.managedapplication.v2018_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.). + + :ivar error: The error object. + :vartype error: ~azure.mgmt.managedapplication.v2018_06_01.models.ErrorDetail + """ + + _attribute_map = { + 'error': {'key': 'error', 'type': 'ErrorDetail'}, + } + + def __init__( + self, + *, + error: Optional["_models.ErrorDetail"] = None, + **kwargs + ): + """ + :keyword error: The error object. + :paramtype error: ~azure.mgmt.managedapplication.v2018_06_01.models.ErrorDetail + """ + super(ErrorResponse, self).__init__(**kwargs) + self.error = error + + +class Identity(msrest.serialization.Model): + """Identity for the resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar principal_id: The principal ID of resource identity. + :vartype principal_id: str + :ivar tenant_id: The tenant ID of resource. + :vartype tenant_id: str + :ivar type: The identity type. Known values are: "SystemAssigned", "UserAssigned", + "SystemAssigned, UserAssigned", "None". + :vartype type: str or ~azure.mgmt.managedapplication.v2018_06_01.models.ResourceIdentityType + :ivar user_assigned_identities: The list of user identities associated with the resource. The + user identity dictionary key references will be resource ids in the form: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'. + :vartype user_assigned_identities: dict[str, + ~azure.mgmt.managedapplication.v2018_06_01.models.UserAssignedResourceIdentity] + """ + + _validation = { + 'principal_id': {'readonly': True}, + 'tenant_id': {'readonly': True}, + } + + _attribute_map = { + 'principal_id': {'key': 'principalId', 'type': 'str'}, + 'tenant_id': {'key': 'tenantId', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'user_assigned_identities': {'key': 'userAssignedIdentities', 'type': '{UserAssignedResourceIdentity}'}, + } + + def __init__( + self, + *, + type: Optional[Union[str, "_models.ResourceIdentityType"]] = None, + user_assigned_identities: Optional[Dict[str, "_models.UserAssignedResourceIdentity"]] = None, + **kwargs + ): + """ + :keyword type: The identity type. Known values are: "SystemAssigned", "UserAssigned", + "SystemAssigned, UserAssigned", "None". + :paramtype type: str or ~azure.mgmt.managedapplication.v2018_06_01.models.ResourceIdentityType + :keyword user_assigned_identities: The list of user identities associated with the resource. + The user identity dictionary key references will be resource ids in the form: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'. + :paramtype user_assigned_identities: dict[str, + ~azure.mgmt.managedapplication.v2018_06_01.models.UserAssignedResourceIdentity] + """ + super(Identity, self).__init__(**kwargs) + self.principal_id = None + self.tenant_id = None + self.type = type + self.user_assigned_identities = user_assigned_identities + + +class JitApproverDefinition(msrest.serialization.Model): + """JIT approver definition. + + All required parameters must be populated in order to send to Azure. + + :ivar id: Required. The approver service principal Id. + :vartype id: str + :ivar type: The approver type. Known values are: "user", "group". + :vartype type: str or ~azure.mgmt.managedapplication.v2018_06_01.models.JitApproverType + :ivar display_name: The approver display name. + :vartype display_name: str + """ + + _validation = { + 'id': {'required': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'display_name': {'key': 'displayName', 'type': 'str'}, + } + + def __init__( + self, + *, + id: str, + type: Optional[Union[str, "_models.JitApproverType"]] = None, + display_name: Optional[str] = None, + **kwargs + ): + """ + :keyword id: Required. The approver service principal Id. + :paramtype id: str + :keyword type: The approver type. Known values are: "user", "group". + :paramtype type: str or ~azure.mgmt.managedapplication.v2018_06_01.models.JitApproverType + :keyword display_name: The approver display name. + :paramtype display_name: str + """ + super(JitApproverDefinition, self).__init__(**kwargs) + self.id = id + self.type = type + self.display_name = display_name + + +class JitAuthorizationPolicies(msrest.serialization.Model): + """The JIT authorization policies. + + All required parameters must be populated in order to send to Azure. + + :ivar principal_id: Required. The the principal id that will be granted JIT access. + :vartype principal_id: str + :ivar role_definition_id: Required. The role definition id that will be granted to the + Principal. + :vartype role_definition_id: str + """ + + _validation = { + 'principal_id': {'required': True}, + 'role_definition_id': {'required': True}, + } + + _attribute_map = { + 'principal_id': {'key': 'principalId', 'type': 'str'}, + 'role_definition_id': {'key': 'roleDefinitionId', 'type': 'str'}, + } + + def __init__( + self, + *, + principal_id: str, + role_definition_id: str, + **kwargs + ): + """ + :keyword principal_id: Required. The the principal id that will be granted JIT access. + :paramtype principal_id: str + :keyword role_definition_id: Required. The role definition id that will be granted to the + Principal. + :paramtype role_definition_id: str + """ + super(JitAuthorizationPolicies, self).__init__(**kwargs) + self.principal_id = principal_id + self.role_definition_id = role_definition_id + + +class JitRequestDefinition(Resource): + """Information about JIT request definition. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Resource ID. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar location: Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar application_resource_id: The parent application id. + :vartype application_resource_id: str + :ivar publisher_tenant_id: The publisher tenant id. + :vartype publisher_tenant_id: str + :ivar jit_authorization_policies: The JIT authorization policies. + :vartype jit_authorization_policies: + list[~azure.mgmt.managedapplication.v2018_06_01.models.JitAuthorizationPolicies] + :ivar jit_scheduling_policy: The JIT request properties. + :vartype jit_scheduling_policy: + ~azure.mgmt.managedapplication.v2018_06_01.models.JitSchedulingPolicy + :ivar provisioning_state: The JIT request provisioning state. Known values are: "NotSpecified", + "Accepted", "Running", "Ready", "Creating", "Created", "Deleting", "Deleted", "Canceled", + "Failed", "Succeeded", "Updating". + :vartype provisioning_state: str or + ~azure.mgmt.managedapplication.v2018_06_01.models.ProvisioningState + :ivar jit_request_state: The JIT request state. Known values are: "NotSpecified", "Pending", + "Approved", "Denied", "Failed", "Canceled", "Expired", "Timeout". + :vartype jit_request_state: str or + ~azure.mgmt.managedapplication.v2018_06_01.models.JitRequestState + :ivar created_by: The client entity that created the JIT request. + :vartype created_by: ~azure.mgmt.managedapplication.v2018_06_01.models.ApplicationClientDetails + :ivar updated_by: The client entity that last updated the JIT request. + :vartype updated_by: ~azure.mgmt.managedapplication.v2018_06_01.models.ApplicationClientDetails + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'publisher_tenant_id': {'readonly': True}, + 'provisioning_state': {'readonly': True}, + 'jit_request_state': {'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'}, + 'location': {'key': 'location', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + 'application_resource_id': {'key': 'properties.applicationResourceId', 'type': 'str'}, + 'publisher_tenant_id': {'key': 'properties.publisherTenantId', 'type': 'str'}, + 'jit_authorization_policies': {'key': 'properties.jitAuthorizationPolicies', 'type': '[JitAuthorizationPolicies]'}, + 'jit_scheduling_policy': {'key': 'properties.jitSchedulingPolicy', 'type': 'JitSchedulingPolicy'}, + 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + 'jit_request_state': {'key': 'properties.jitRequestState', 'type': 'str'}, + 'created_by': {'key': 'properties.createdBy', 'type': 'ApplicationClientDetails'}, + 'updated_by': {'key': 'properties.updatedBy', 'type': 'ApplicationClientDetails'}, + } + + def __init__( + self, + *, + location: Optional[str] = None, + tags: Optional[Dict[str, str]] = None, + application_resource_id: Optional[str] = None, + jit_authorization_policies: Optional[List["_models.JitAuthorizationPolicies"]] = None, + jit_scheduling_policy: Optional["_models.JitSchedulingPolicy"] = None, + **kwargs + ): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword application_resource_id: The parent application id. + :paramtype application_resource_id: str + :keyword jit_authorization_policies: The JIT authorization policies. + :paramtype jit_authorization_policies: + list[~azure.mgmt.managedapplication.v2018_06_01.models.JitAuthorizationPolicies] + :keyword jit_scheduling_policy: The JIT request properties. + :paramtype jit_scheduling_policy: + ~azure.mgmt.managedapplication.v2018_06_01.models.JitSchedulingPolicy + """ + super(JitRequestDefinition, self).__init__(location=location, tags=tags, **kwargs) + self.application_resource_id = application_resource_id + self.publisher_tenant_id = None + self.jit_authorization_policies = jit_authorization_policies + self.jit_scheduling_policy = jit_scheduling_policy + self.provisioning_state = None + self.jit_request_state = None + self.created_by = None + self.updated_by = None + + +class JitRequestDefinitionListResult(msrest.serialization.Model): + """List of JIT requests. + + :ivar value: The array of Jit request definition. + :vartype value: list[~azure.mgmt.managedapplication.v2018_06_01.models.JitRequestDefinition] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[JitRequestDefinition]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["_models.JitRequestDefinition"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + """ + :keyword value: The array of Jit request definition. + :paramtype value: list[~azure.mgmt.managedapplication.v2018_06_01.models.JitRequestDefinition] + :keyword next_link: The URL to use for getting the next set of results. + :paramtype next_link: str + """ + super(JitRequestDefinitionListResult, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class JitRequestMetadata(msrest.serialization.Model): + """The JIT request metadata. + + :ivar origin_request_id: The origin request id. + :vartype origin_request_id: str + :ivar requestor_id: The requestor id. + :vartype requestor_id: str + :ivar tenant_display_name: The publisher's tenant name. + :vartype tenant_display_name: str + :ivar subject_display_name: The subject display name. + :vartype subject_display_name: str + """ + + _attribute_map = { + 'origin_request_id': {'key': 'originRequestId', 'type': 'str'}, + 'requestor_id': {'key': 'requestorId', 'type': 'str'}, + 'tenant_display_name': {'key': 'tenantDisplayName', 'type': 'str'}, + 'subject_display_name': {'key': 'subjectDisplayName', 'type': 'str'}, + } + + def __init__( + self, + *, + origin_request_id: Optional[str] = None, + requestor_id: Optional[str] = None, + tenant_display_name: Optional[str] = None, + subject_display_name: Optional[str] = None, + **kwargs + ): + """ + :keyword origin_request_id: The origin request id. + :paramtype origin_request_id: str + :keyword requestor_id: The requestor id. + :paramtype requestor_id: str + :keyword tenant_display_name: The publisher's tenant name. + :paramtype tenant_display_name: str + :keyword subject_display_name: The subject display name. + :paramtype subject_display_name: str + """ + super(JitRequestMetadata, self).__init__(**kwargs) + self.origin_request_id = origin_request_id + self.requestor_id = requestor_id + self.tenant_display_name = tenant_display_name + self.subject_display_name = subject_display_name + + +class JitRequestPatchable(msrest.serialization.Model): + """Information about JIT request. + + :ivar tags: A set of tags. Jit request tags. + :vartype tags: dict[str, str] + """ + + _attribute_map = { + 'tags': {'key': 'tags', 'type': '{str}'}, + } + + def __init__( + self, + *, + tags: Optional[Dict[str, str]] = None, + **kwargs + ): + """ + :keyword tags: A set of tags. Jit request tags. + :paramtype tags: dict[str, str] + """ + super(JitRequestPatchable, self).__init__(**kwargs) + self.tags = tags + + +class JitSchedulingPolicy(msrest.serialization.Model): + """The JIT scheduling policies. + + All required parameters must be populated in order to send to Azure. + + :ivar type: Required. The type of JIT schedule. Known values are: "NotSpecified", "Once", + "Recurring". + :vartype type: str or ~azure.mgmt.managedapplication.v2018_06_01.models.JitSchedulingType + :ivar duration: Required. The required duration of the JIT request. + :vartype duration: ~datetime.timedelta + :ivar start_time: Required. The start time of the request. + :vartype start_time: ~datetime.datetime + """ + + _validation = { + 'type': {'required': True}, + 'duration': {'required': True}, + 'start_time': {'required': True}, + } + + _attribute_map = { + 'type': {'key': 'type', 'type': 'str'}, + 'duration': {'key': 'duration', 'type': 'duration'}, + 'start_time': {'key': 'startTime', 'type': 'iso-8601'}, + } + + def __init__( + self, + *, + type: Union[str, "_models.JitSchedulingType"], + duration: datetime.timedelta, + start_time: datetime.datetime, + **kwargs + ): + """ + :keyword type: Required. The type of JIT schedule. Known values are: "NotSpecified", "Once", + "Recurring". + :paramtype type: str or ~azure.mgmt.managedapplication.v2018_06_01.models.JitSchedulingType + :keyword duration: Required. The required duration of the JIT request. + :paramtype duration: ~datetime.timedelta + :keyword start_time: Required. The start time of the request. + :paramtype start_time: ~datetime.datetime + """ + super(JitSchedulingPolicy, self).__init__(**kwargs) + self.type = type + self.duration = duration + self.start_time = start_time + + +class ListTokenRequest(msrest.serialization.Model): + """List token request body. + + :ivar authorization_audience: The authorization audience. + :vartype authorization_audience: str + :ivar user_assigned_identities: The user assigned identities. + :vartype user_assigned_identities: list[str] + """ + + _attribute_map = { + 'authorization_audience': {'key': 'authorizationAudience', 'type': 'str'}, + 'user_assigned_identities': {'key': 'userAssignedIdentities', 'type': '[str]'}, + } + + def __init__( + self, + *, + authorization_audience: Optional[str] = None, + user_assigned_identities: Optional[List[str]] = None, + **kwargs + ): + """ + :keyword authorization_audience: The authorization audience. + :paramtype authorization_audience: str + :keyword user_assigned_identities: The user assigned identities. + :paramtype user_assigned_identities: list[str] + """ + super(ListTokenRequest, self).__init__(**kwargs) + self.authorization_audience = authorization_audience + self.user_assigned_identities = user_assigned_identities + + +class ManagedIdentityToken(msrest.serialization.Model): + """The managed identity token for the managed app resource. + + :ivar access_token: The requested access token. + :vartype access_token: str + :ivar expires_in: The number of seconds the access token will be valid. + :vartype expires_in: str + :ivar expires_on: The timespan when the access token expires. This is represented as the number + of seconds from epoch. + :vartype expires_on: str + :ivar not_before: The timespan when the access token takes effect. This is represented as the + number of seconds from epoch. + :vartype not_before: str + :ivar authorization_audience: The aud (audience) the access token was request for. This is the + same as what was provided in the listTokens request. + :vartype authorization_audience: str + :ivar resource_id: The Azure resource ID for the issued token. This is either the managed + application ID or the user-assigned identity ID. + :vartype resource_id: str + :ivar token_type: The type of the token. + :vartype token_type: str + """ + + _attribute_map = { + 'access_token': {'key': 'accessToken', 'type': 'str'}, + 'expires_in': {'key': 'expiresIn', 'type': 'str'}, + 'expires_on': {'key': 'expiresOn', 'type': 'str'}, + 'not_before': {'key': 'notBefore', 'type': 'str'}, + 'authorization_audience': {'key': 'authorizationAudience', 'type': 'str'}, + 'resource_id': {'key': 'resourceId', 'type': 'str'}, + 'token_type': {'key': 'tokenType', 'type': 'str'}, + } + + def __init__( + self, + *, + access_token: Optional[str] = None, + expires_in: Optional[str] = None, + expires_on: Optional[str] = None, + not_before: Optional[str] = None, + authorization_audience: Optional[str] = None, + resource_id: Optional[str] = None, + token_type: Optional[str] = None, + **kwargs + ): + """ + :keyword access_token: The requested access token. + :paramtype access_token: str + :keyword expires_in: The number of seconds the access token will be valid. + :paramtype expires_in: str + :keyword expires_on: The timespan when the access token expires. This is represented as the + number of seconds from epoch. + :paramtype expires_on: str + :keyword not_before: The timespan when the access token takes effect. This is represented as + the number of seconds from epoch. + :paramtype not_before: str + :keyword authorization_audience: The aud (audience) the access token was request for. This is + the same as what was provided in the listTokens request. + :paramtype authorization_audience: str + :keyword resource_id: The Azure resource ID for the issued token. This is either the managed + application ID or the user-assigned identity ID. + :paramtype resource_id: str + :keyword token_type: The type of the token. + :paramtype token_type: str + """ + super(ManagedIdentityToken, self).__init__(**kwargs) + self.access_token = access_token + self.expires_in = expires_in + self.expires_on = expires_on + self.not_before = not_before + self.authorization_audience = authorization_audience + self.resource_id = resource_id + self.token_type = token_type + + +class ManagedIdentityTokenResult(msrest.serialization.Model): + """The array of managed identity tokens. + + :ivar value: The array of managed identity tokens. + :vartype value: list[~azure.mgmt.managedapplication.v2018_06_01.models.ManagedIdentityToken] + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[ManagedIdentityToken]'}, + } + + def __init__( + self, + *, + value: Optional[List["_models.ManagedIdentityToken"]] = None, + **kwargs + ): + """ + :keyword value: The array of managed identity tokens. + :paramtype value: list[~azure.mgmt.managedapplication.v2018_06_01.models.ManagedIdentityToken] + """ + super(ManagedIdentityTokenResult, self).__init__(**kwargs) + self.value = value + + +class Operation(msrest.serialization.Model): + """Details of a REST API operation, returned from the Resource Provider Operations API. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name: The name of the operation, as per Resource-Based Access Control (RBAC). Examples: + "Microsoft.Compute/virtualMachines/write", "Microsoft.Compute/virtualMachines/capture/action". + :vartype name: str + :ivar is_data_action: Whether the operation applies to data-plane. This is "true" for + data-plane operations and "false" for ARM/control-plane operations. + :vartype is_data_action: bool + :ivar display: Localized display information for this particular operation. + :vartype display: ~azure.mgmt.managedapplication.v2018_06_01.models.OperationDisplay + :ivar origin: The intended executor of the operation; as in Resource Based Access Control + (RBAC) and audit logs UX. Default value is "user,system". Known values are: "user", "system", + "user,system". + :vartype origin: str or ~azure.mgmt.managedapplication.v2018_06_01.models.Origin + :ivar action_type: Enum. Indicates the action type. "Internal" refers to actions that are for + internal only APIs. Known values are: "Internal". + :vartype action_type: str or ~azure.mgmt.managedapplication.v2018_06_01.models.ActionType + """ + + _validation = { + 'name': {'readonly': True}, + 'is_data_action': {'readonly': True}, + 'origin': {'readonly': True}, + 'action_type': {'readonly': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'is_data_action': {'key': 'isDataAction', 'type': 'bool'}, + 'display': {'key': 'display', 'type': 'OperationDisplay'}, + 'origin': {'key': 'origin', 'type': 'str'}, + 'action_type': {'key': 'actionType', 'type': 'str'}, + } + + def __init__( + self, + *, + display: Optional["_models.OperationDisplay"] = None, + **kwargs + ): + """ + :keyword display: Localized display information for this particular operation. + :paramtype display: ~azure.mgmt.managedapplication.v2018_06_01.models.OperationDisplay + """ + super(Operation, self).__init__(**kwargs) + self.name = None + self.is_data_action = None + self.display = display + self.origin = None + self.action_type = None + + +class OperationAutoGenerated(msrest.serialization.Model): + """Microsoft.Solutions operation. + + :ivar name: Operation name: {provider}/{resource}/{operation}. + :vartype name: str + :ivar display: The object that represents the operation. + :vartype display: + ~azure.mgmt.managedapplication.v2018_06_01.models.OperationDisplayAutoGenerated + """ + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'display': {'key': 'display', 'type': 'OperationDisplayAutoGenerated'}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + display: Optional["_models.OperationDisplayAutoGenerated"] = None, + **kwargs + ): + """ + :keyword name: Operation name: {provider}/{resource}/{operation}. + :paramtype name: str + :keyword display: The object that represents the operation. + :paramtype display: + ~azure.mgmt.managedapplication.v2018_06_01.models.OperationDisplayAutoGenerated + """ + super(OperationAutoGenerated, self).__init__(**kwargs) + self.name = name + self.display = display + + +class OperationDisplay(msrest.serialization.Model): + """Localized display information for this particular operation. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar provider: The localized friendly form of the resource provider name, e.g. "Microsoft + Monitoring Insights" or "Microsoft Compute". + :vartype provider: str + :ivar resource: The localized friendly name of the resource type related to this operation. + E.g. "Virtual Machines" or "Job Schedule Collections". + :vartype resource: str + :ivar operation: The concise, localized friendly name for the operation; suitable for + dropdowns. E.g. "Create or Update Virtual Machine", "Restart Virtual Machine". + :vartype operation: str + :ivar description: The short, localized friendly description of the operation; suitable for + tool tips and detailed views. + :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 OperationDisplayAutoGenerated(msrest.serialization.Model): + """The object that represents the operation. + + :ivar provider: Service provider: Microsoft.Solutions. + :vartype provider: str + :ivar resource: Resource on which the operation is performed: Application, JitRequest, etc. + :vartype resource: str + :ivar operation: Operation type: Read, write, delete, etc. + :vartype operation: str + """ + + _attribute_map = { + 'provider': {'key': 'provider', 'type': 'str'}, + 'resource': {'key': 'resource', 'type': 'str'}, + 'operation': {'key': 'operation', 'type': 'str'}, + } + + def __init__( + self, + *, + provider: Optional[str] = None, + resource: Optional[str] = None, + operation: Optional[str] = None, + **kwargs + ): + """ + :keyword provider: Service provider: Microsoft.Solutions. + :paramtype provider: str + :keyword resource: Resource on which the operation is performed: Application, JitRequest, etc. + :paramtype resource: str + :keyword operation: Operation type: Read, write, delete, etc. + :paramtype operation: str + """ + super(OperationDisplayAutoGenerated, self).__init__(**kwargs) + self.provider = provider + self.resource = resource + self.operation = operation + + +class OperationListResult(msrest.serialization.Model): + """A list of REST API operations supported by an Azure Resource Provider. It contains an URL link to get the next set of results. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: List of operations supported by the resource provider. + :vartype value: list[~azure.mgmt.managedapplication.v2018_06_01.models.Operation] + :ivar next_link: URL to get the next set of operation list results (if there are any). + :vartype next_link: str + """ + + _validation = { + 'value': {'readonly': True}, + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Operation]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(OperationListResult, self).__init__(**kwargs) + self.value = None + self.next_link = None + + +class Plan(msrest.serialization.Model): + """Plan for the managed application. + + All required parameters must be populated in order to send to Azure. + + :ivar name: Required. The plan name. + :vartype name: str + :ivar publisher: Required. The publisher ID. + :vartype publisher: str + :ivar product: Required. The product code. + :vartype product: str + :ivar promotion_code: The promotion code. + :vartype promotion_code: str + :ivar version: Required. The plan's version. + :vartype version: str + """ + + _validation = { + 'name': {'required': True}, + 'publisher': {'required': True}, + 'product': {'required': True}, + 'version': {'required': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'publisher': {'key': 'publisher', 'type': 'str'}, + 'product': {'key': 'product', 'type': 'str'}, + 'promotion_code': {'key': 'promotionCode', 'type': 'str'}, + 'version': {'key': 'version', 'type': 'str'}, + } + + def __init__( + self, + *, + name: str, + publisher: str, + product: str, + version: str, + promotion_code: Optional[str] = None, + **kwargs + ): + """ + :keyword name: Required. The plan name. + :paramtype name: str + :keyword publisher: Required. The publisher ID. + :paramtype publisher: str + :keyword product: Required. The product code. + :paramtype product: str + :keyword promotion_code: The promotion code. + :paramtype promotion_code: str + :keyword version: Required. The plan's version. + :paramtype version: str + """ + super(Plan, self).__init__(**kwargs) + self.name = name + self.publisher = publisher + self.product = product + self.promotion_code = promotion_code + self.version = version + + +class PlanPatchable(msrest.serialization.Model): + """Plan for the managed application. + + :ivar name: The plan name. + :vartype name: str + :ivar publisher: The publisher ID. + :vartype publisher: str + :ivar product: The product code. + :vartype product: str + :ivar promotion_code: The promotion code. + :vartype promotion_code: str + :ivar version: The plan's version. + :vartype version: str + """ + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'publisher': {'key': 'publisher', 'type': 'str'}, + 'product': {'key': 'product', 'type': 'str'}, + 'promotion_code': {'key': 'promotionCode', 'type': 'str'}, + 'version': {'key': 'version', 'type': 'str'}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + publisher: Optional[str] = None, + product: Optional[str] = None, + promotion_code: Optional[str] = None, + version: Optional[str] = None, + **kwargs + ): + """ + :keyword name: The plan name. + :paramtype name: str + :keyword publisher: The publisher ID. + :paramtype publisher: str + :keyword product: The product code. + :paramtype product: str + :keyword promotion_code: The promotion code. + :paramtype promotion_code: str + :keyword version: The plan's version. + :paramtype version: str + """ + super(PlanPatchable, self).__init__(**kwargs) + self.name = name + self.publisher = publisher + self.product = product + self.promotion_code = promotion_code + self.version = version + + +class Sku(msrest.serialization.Model): + """SKU for the resource. + + All required parameters must be populated in order to send to Azure. + + :ivar name: Required. The SKU name. + :vartype name: str + :ivar tier: The SKU tier. + :vartype tier: str + :ivar size: The SKU size. + :vartype size: str + :ivar family: The SKU family. + :vartype family: str + :ivar model: The SKU model. + :vartype model: str + :ivar capacity: The SKU capacity. + :vartype capacity: int + """ + + _validation = { + 'name': {'required': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'tier': {'key': 'tier', 'type': 'str'}, + 'size': {'key': 'size', 'type': 'str'}, + 'family': {'key': 'family', 'type': 'str'}, + 'model': {'key': 'model', 'type': 'str'}, + 'capacity': {'key': 'capacity', 'type': 'int'}, + } + + def __init__( + self, + *, + name: str, + tier: Optional[str] = None, + size: Optional[str] = None, + family: Optional[str] = None, + model: Optional[str] = None, + capacity: Optional[int] = None, + **kwargs + ): + """ + :keyword name: Required. The SKU name. + :paramtype name: str + :keyword tier: The SKU tier. + :paramtype tier: str + :keyword size: The SKU size. + :paramtype size: str + :keyword family: The SKU family. + :paramtype family: str + :keyword model: The SKU model. + :paramtype model: str + :keyword capacity: The SKU capacity. + :paramtype capacity: int + """ + super(Sku, self).__init__(**kwargs) + self.name = name + self.tier = tier + self.size = size + self.family = family + self.model = model + self.capacity = capacity + + +class UpdateAccessDefinition(msrest.serialization.Model): + """Update access request definition. + + All required parameters must be populated in order to send to Azure. + + :ivar approver: The approver name. + :vartype approver: str + :ivar metadata: Required. The JIT request metadata. + :vartype metadata: ~azure.mgmt.managedapplication.v2018_06_01.models.JitRequestMetadata + :ivar status: Required. The JIT status. Known values are: "NotSpecified", "Elevate", "Remove". + :vartype status: str or ~azure.mgmt.managedapplication.v2018_06_01.models.Status + :ivar sub_status: Required. The JIT status. Known values are: "NotSpecified", "Approved", + "Denied", "Failed", "Expired", "Timeout". + :vartype sub_status: str or ~azure.mgmt.managedapplication.v2018_06_01.models.Substatus + """ + + _validation = { + 'metadata': {'required': True}, + 'status': {'required': True}, + 'sub_status': {'required': True}, + } + + _attribute_map = { + 'approver': {'key': 'approver', 'type': 'str'}, + 'metadata': {'key': 'metadata', 'type': 'JitRequestMetadata'}, + 'status': {'key': 'status', 'type': 'str'}, + 'sub_status': {'key': 'subStatus', 'type': 'str'}, + } + + def __init__( + self, + *, + metadata: "_models.JitRequestMetadata", + status: Union[str, "_models.Status"], + sub_status: Union[str, "_models.Substatus"], + approver: Optional[str] = None, + **kwargs + ): + """ + :keyword approver: The approver name. + :paramtype approver: str + :keyword metadata: Required. The JIT request metadata. + :paramtype metadata: ~azure.mgmt.managedapplication.v2018_06_01.models.JitRequestMetadata + :keyword status: Required. The JIT status. Known values are: "NotSpecified", "Elevate", + "Remove". + :paramtype status: str or ~azure.mgmt.managedapplication.v2018_06_01.models.Status + :keyword sub_status: Required. The JIT status. Known values are: "NotSpecified", "Approved", + "Denied", "Failed", "Expired", "Timeout". + :paramtype sub_status: str or ~azure.mgmt.managedapplication.v2018_06_01.models.Substatus + """ + super(UpdateAccessDefinition, self).__init__(**kwargs) + self.approver = approver + self.metadata = metadata + self.status = status + self.sub_status = sub_status + + +class UserAssignedResourceIdentity(msrest.serialization.Model): + """Represents the user assigned identity that is contained within the UserAssignedIdentities dictionary on ResourceIdentity. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar principal_id: The principal id of user assigned identity. + :vartype principal_id: str + :ivar tenant_id: The tenant id of user assigned identity. + :vartype tenant_id: str + """ + + _validation = { + 'principal_id': {'readonly': True}, + 'tenant_id': {'readonly': True}, + } + + _attribute_map = { + 'principal_id': {'key': 'principalId', 'type': 'str'}, + 'tenant_id': {'key': 'tenantId', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(UserAssignedResourceIdentity, self).__init__(**kwargs) + self.principal_id = None + self.tenant_id = None diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_06_01/models/_patch.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_06_01/models/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_06_01/models/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_06_01/operations/__init__.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_06_01/operations/__init__.py new file mode 100644 index 000000000000..b93ecbbe65e2 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_06_01/operations/__init__.py @@ -0,0 +1,24 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._application_client_operations import ApplicationClientOperationsMixin +from ._applications_operations import ApplicationsOperations +from ._application_definitions_operations import ApplicationDefinitionsOperations +from ._jit_requests_operations import JitRequestsOperations + +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk +__all__ = [ + 'ApplicationClientOperationsMixin', + 'ApplicationsOperations', + 'ApplicationDefinitionsOperations', + 'JitRequestsOperations', +] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_06_01/operations/_application_client_operations.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_06_01/operations/_application_client_operations.py new file mode 100644 index 000000000000..4c684d3ae8dd --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_06_01/operations/_application_client_operations.py @@ -0,0 +1,134 @@ +# 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.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._vendor import MixinABC, _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_operations_request( + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.Solutions/operations") + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + +class ApplicationClientOperationsMixin(MixinABC): + + @distributed_trace + def list_operations( + self, + **kwargs: Any + ) -> Iterable[_models.OperationListResult]: + """Lists all of the available Microsoft.Solutions REST API operations. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either OperationListResult or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.managedapplication.v2018_06_01.models.OperationListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # 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', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_operations_request( + api_version=api_version, + template_url=self.list_operations.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_operations_request( + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list_operations.metadata = {'url': "/providers/Microsoft.Solutions/operations"} # type: ignore diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_06_01/operations/_application_definitions_operations.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_06_01/operations/_application_definitions_operations.py new file mode 100644 index 000000000000..dc36cbe88577 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_06_01/operations/_application_definitions_operations.py @@ -0,0 +1,1158 @@ +# 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.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._vendor import MixinABC, _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_request( + resource_group_name: str, + application_definition_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "applicationDefinitionName": _SERIALIZER.url("application_definition_name", application_definition_name, 'str', max_length=64, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_delete_request( + resource_group_name: str, + application_definition_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "applicationDefinitionName": _SERIALIZER.url("application_definition_name", application_definition_name, 'str', max_length=64, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_create_or_update_request( + resource_group_name: str, + application_definition_name: str, + subscription_id: str, + *, + json: Optional[_models.ApplicationDefinition] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "applicationDefinitionName": _SERIALIZER.url("application_definition_name", application_definition_name, 'str', max_length=64, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_update_request( + subscription_id: str, + resource_group_name: str, + application_definition_name: str, + *, + json: Optional[_models.ApplicationDefinitionPatchable] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "applicationDefinitionName": _SERIALIZER.url("application_definition_name", application_definition_name, 'str', max_length=64, min_length=3), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_list_by_resource_group_request( + resource_group_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_list_by_subscription_request( + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Solutions/applicationDefinitions") + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_get_by_id_request( + resource_group_name: str, + application_definition_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "applicationDefinitionName": _SERIALIZER.url("application_definition_name", application_definition_name, 'str', max_length=64, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_delete_by_id_request( + resource_group_name: str, + application_definition_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "applicationDefinitionName": _SERIALIZER.url("application_definition_name", application_definition_name, 'str', max_length=64, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_create_or_update_by_id_request( + resource_group_name: str, + application_definition_name: str, + subscription_id: str, + *, + json: Optional[_models.ApplicationDefinition] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "applicationDefinitionName": _SERIALIZER.url("application_definition_name", application_definition_name, 'str', max_length=64, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_update_by_id_request( + subscription_id: str, + resource_group_name: str, + application_definition_name: str, + *, + json: Optional[_models.ApplicationDefinitionPatchable] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "applicationDefinitionName": _SERIALIZER.url("application_definition_name", application_definition_name, 'str', max_length=64, min_length=3), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + +class ApplicationDefinitionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.managedapplication.v2018_06_01.ApplicationClient`'s + :attr:`application_definitions` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + + @distributed_trace + def get( + self, + resource_group_name: str, + application_definition_name: str, + **kwargs: Any + ) -> Optional[_models.ApplicationDefinition]: + """Gets the managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. + :type application_definition_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ApplicationDefinition, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2018_06_01.models.ApplicationDefinition or None + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.ApplicationDefinition]] + + + request = build_get_request( + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('ApplicationDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore + + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + application_definition_name: str, + **kwargs: Any + ) -> None: + """Deletes the managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition to delete. + :type application_definition_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_request( + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore + + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + application_definition_name: str, + parameters: _models.ApplicationDefinition, + **kwargs: Any + ) -> _models.ApplicationDefinition: + """Creates or updates a managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. + :type application_definition_name: str + :param parameters: Parameters supplied to the create or update an managed application + definition. + :type parameters: ~azure.mgmt.managedapplication.v2018_06_01.models.ApplicationDefinition + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ApplicationDefinition, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2018_06_01.models.ApplicationDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationDefinition] + + _json = self._serialize.body(parameters, 'ApplicationDefinition') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # 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, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('ApplicationDefinition', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('ApplicationDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore + + + @distributed_trace + def update( + self, + resource_group_name: str, + application_definition_name: str, + parameters: _models.ApplicationDefinitionPatchable, + **kwargs: Any + ) -> _models.ApplicationDefinition: + """Updates the managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. + :type application_definition_name: str + :param parameters: Parameters supplied to the update a managed application definition. + :type parameters: + ~azure.mgmt.managedapplication.v2018_06_01.models.ApplicationDefinitionPatchable + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ApplicationDefinition, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2018_06_01.models.ApplicationDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationDefinition] + + _json = self._serialize.body(parameters, 'ApplicationDefinitionPatchable') + + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ApplicationDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore + + + @distributed_trace + def list_by_resource_group( + self, + resource_group_name: str, + **kwargs: Any + ) -> Iterable[_models.ApplicationDefinitionListResult]: + """Lists the managed application definitions in a resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ApplicationDefinitionListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.managedapplication.v2018_06_01.models.ApplicationDefinitionListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationDefinitionListResult] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_resource_group.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ApplicationDefinitionListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions"} # type: ignore + + @distributed_trace + def list_by_subscription( + self, + **kwargs: Any + ) -> Iterable[_models.ApplicationDefinitionListResult]: + """Lists the managed application definitions in a subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ApplicationDefinitionListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.managedapplication.v2018_06_01.models.ApplicationDefinitionListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationDefinitionListResult] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ApplicationDefinitionListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Solutions/applicationDefinitions"} # type: ignore + + @distributed_trace + def get_by_id( + self, + resource_group_name: str, + application_definition_name: str, + **kwargs: Any + ) -> Optional[_models.ApplicationDefinition]: + """Gets the managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. + :type application_definition_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ApplicationDefinition, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2018_06_01.models.ApplicationDefinition or None + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.ApplicationDefinition]] + + + request = build_get_by_id_request( + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_by_id.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('ApplicationDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_by_id.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore + + + @distributed_trace + def delete_by_id( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + application_definition_name: str, + **kwargs: Any + ) -> None: + """Deletes the managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. + :type application_definition_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_by_id_request( + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete_by_id.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete_by_id.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore + + + @distributed_trace + def create_or_update_by_id( + self, + resource_group_name: str, + application_definition_name: str, + parameters: _models.ApplicationDefinition, + **kwargs: Any + ) -> _models.ApplicationDefinition: + """Creates or updates a managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. + :type application_definition_name: str + :param parameters: Parameters supplied to the create or update a managed application + definition. + :type parameters: ~azure.mgmt.managedapplication.v2018_06_01.models.ApplicationDefinition + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ApplicationDefinition, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2018_06_01.models.ApplicationDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationDefinition] + + _json = self._serialize.body(parameters, 'ApplicationDefinition') + + request = build_create_or_update_by_id_request( + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + 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'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # 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, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('ApplicationDefinition', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('ApplicationDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_or_update_by_id.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore + + + @distributed_trace + def update_by_id( + self, + resource_group_name: str, + application_definition_name: str, + parameters: _models.ApplicationDefinitionPatchable, + **kwargs: Any + ) -> _models.ApplicationDefinition: + """Updates the managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. + :type application_definition_name: str + :param parameters: Parameters supplied to the update a managed application definition. + :type parameters: + ~azure.mgmt.managedapplication.v2018_06_01.models.ApplicationDefinitionPatchable + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ApplicationDefinition, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2018_06_01.models.ApplicationDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationDefinition] + + _json = self._serialize.body(parameters, 'ApplicationDefinitionPatchable') + + request = build_update_by_id_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.update_by_id.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ApplicationDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + update_by_id.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore + diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_06_01/operations/_applications_operations.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_06_01/operations/_applications_operations.py new file mode 100644 index 000000000000..75cfd5b30d56 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_06_01/operations/_applications_operations.py @@ -0,0 +1,1989 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast + +from msrest import Serializer + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from .._vendor import MixinABC, _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_request( + resource_group_name: str, + application_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "applicationName": _SERIALIZER.url("application_name", application_name, 'str', max_length=64, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_delete_request_initial( + resource_group_name: str, + application_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "applicationName": _SERIALIZER.url("application_name", application_name, 'str', max_length=64, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_create_or_update_request_initial( + resource_group_name: str, + application_name: str, + subscription_id: str, + *, + json: Optional[_models.Application] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "applicationName": _SERIALIZER.url("application_name", application_name, 'str', max_length=64, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_update_request_initial( + resource_group_name: str, + application_name: str, + subscription_id: str, + *, + json: Optional[_models.ApplicationPatchable] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "applicationName": _SERIALIZER.url("application_name", application_name, 'str', max_length=64, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_list_by_resource_group_request( + resource_group_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_list_by_subscription_request( + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Solutions/applications") + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_get_by_id_request( + application_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/{applicationId}") + path_format_arguments = { + "applicationId": _SERIALIZER.url("application_id", application_id, 'str', skip_quote=True), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_delete_by_id_request_initial( + application_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/{applicationId}") + path_format_arguments = { + "applicationId": _SERIALIZER.url("application_id", application_id, 'str', skip_quote=True), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_create_or_update_by_id_request_initial( + application_id: str, + *, + json: Optional[_models.Application] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/{applicationId}") + path_format_arguments = { + "applicationId": _SERIALIZER.url("application_id", application_id, 'str', skip_quote=True), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_update_by_id_request_initial( + application_id: str, + *, + json: Optional[_models.ApplicationPatchable] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/{applicationId}") + path_format_arguments = { + "applicationId": _SERIALIZER.url("application_id", application_id, 'str', skip_quote=True), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_refresh_permissions_request_initial( + resource_group_name: str, + application_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}/refreshPermissions") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "applicationName": _SERIALIZER.url("application_name", application_name, 'str', max_length=64, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_update_access_request_initial( + subscription_id: str, + resource_group_name: str, + application_name: str, + *, + json: Optional[_models.UpdateAccessDefinition] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}/updateAccess") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "applicationName": _SERIALIZER.url("application_name", application_name, 'str', max_length=64, min_length=3), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_list_tokens_request( + subscription_id: str, + resource_group_name: str, + application_name: str, + *, + json: Optional[_models.ListTokenRequest] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}/listTokens") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "applicationName": _SERIALIZER.url("application_name", application_name, 'str', max_length=64, min_length=3), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + +class ApplicationsOperations: # pylint: disable=too-many-public-methods + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.managedapplication.v2018_06_01.ApplicationClient`'s + :attr:`applications` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + + @distributed_trace + def get( + self, + resource_group_name: str, + application_name: str, + **kwargs: Any + ) -> Optional[_models.Application]: + """Gets the managed application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_name: The name of the managed application. + :type application_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Application, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2018_06_01.models.Application or None + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.Application]] + + + request = build_get_request( + resource_group_name=resource_group_name, + application_name=application_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('Application', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}"} # type: ignore + + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + application_name: str, + **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + application_name=application_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}"} # type: ignore + + + @distributed_trace + def begin_delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + application_name: str, + **kwargs: Any + ) -> LROPoller[None]: + """Deletes the managed application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_name: The name of the managed application. + :type application_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._delete_initial( # type: ignore + resource_group_name=resource_group_name, + application_name=application_name, + api_version=api_version, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}"} # type: ignore + + def _create_or_update_initial( + self, + resource_group_name: str, + application_name: str, + parameters: _models.Application, + **kwargs: Any + ) -> _models.Application: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Application] + + _json = self._serialize.body(parameters, 'Application') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + application_name=application_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('Application', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('Application', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}"} # type: ignore + + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + application_name: str, + parameters: _models.Application, + **kwargs: Any + ) -> LROPoller[_models.Application]: + """Creates or updates a managed application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_name: The name of the managed application. + :type application_name: str + :param parameters: Parameters supplied to the create or update a managed application. + :type parameters: ~azure.mgmt.managedapplication.v2018_06_01.models.Application + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Application or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.managedapplication.v2018_06_01.models.Application] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Application] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._create_or_update_initial( # type: ignore + resource_group_name=resource_group_name, + application_name=application_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('Application', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}"} # type: ignore + + def _update_initial( + self, + resource_group_name: str, + application_name: str, + parameters: Optional[_models.ApplicationPatchable] = None, + **kwargs: Any + ) -> _models.ApplicationPatchable: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationPatchable] + + if parameters is not None: + _json = self._serialize.body(parameters, 'ApplicationPatchable') + else: + _json = None + + request = build_update_request_initial( + resource_group_name=resource_group_name, + application_name=application_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('ApplicationPatchable', pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize('ApplicationPatchable', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}"} # type: ignore + + + @distributed_trace + def begin_update( + self, + resource_group_name: str, + application_name: str, + parameters: Optional[_models.ApplicationPatchable] = None, + **kwargs: Any + ) -> LROPoller[_models.ApplicationPatchable]: + """Updates an existing managed application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_name: The name of the managed application. + :type application_name: str + :param parameters: Parameters supplied to update an existing managed application. Default value + is None. + :type parameters: ~azure.mgmt.managedapplication.v2018_06_01.models.ApplicationPatchable + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ApplicationPatchable or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.managedapplication.v2018_06_01.models.ApplicationPatchable] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationPatchable] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._update_initial( # type: ignore + resource_group_name=resource_group_name, + application_name=application_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('ApplicationPatchable', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}"} # type: ignore + + @distributed_trace + def list_by_resource_group( + self, + resource_group_name: str, + **kwargs: Any + ) -> Iterable[_models.ApplicationListResult]: + """Lists all the applications within a resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ApplicationListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.managedapplication.v2018_06_01.models.ApplicationListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationListResult] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_resource_group.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ApplicationListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications"} # type: ignore + + @distributed_trace + def list_by_subscription( + self, + **kwargs: Any + ) -> Iterable[_models.ApplicationListResult]: + """Lists all the applications within a subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ApplicationListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.managedapplication.v2018_06_01.models.ApplicationListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationListResult] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ApplicationListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Solutions/applications"} # type: ignore + + @distributed_trace + def get_by_id( + self, + application_id: str, + **kwargs: Any + ) -> Optional[_models.Application]: + """Gets the managed application. + + :param application_id: The fully qualified ID of the managed application, including the managed + application name and the managed application resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/Microsoft.Solutions/applications/{application-name}. + :type application_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Application, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2018_06_01.models.Application or None + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.Application]] + + + request = build_get_by_id_request( + application_id=application_id, + api_version=api_version, + template_url=self.get_by_id.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('Application', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_by_id.metadata = {'url': "/{applicationId}"} # type: ignore + + + def _delete_by_id_initial( # pylint: disable=inconsistent-return-statements + self, + application_id: str, + **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_by_id_request_initial( + application_id=application_id, + api_version=api_version, + template_url=self._delete_by_id_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_by_id_initial.metadata = {'url': "/{applicationId}"} # type: ignore + + + @distributed_trace + def begin_delete_by_id( # pylint: disable=inconsistent-return-statements + self, + application_id: str, + **kwargs: Any + ) -> LROPoller[None]: + """Deletes the managed application. + + :param application_id: The fully qualified ID of the managed application, including the managed + application name and the managed application resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/Microsoft.Solutions/applications/{application-name}. + :type application_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._delete_by_id_initial( # type: ignore + application_id=application_id, + api_version=api_version, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete_by_id.metadata = {'url': "/{applicationId}"} # type: ignore + + def _create_or_update_by_id_initial( + self, + application_id: str, + parameters: _models.Application, + **kwargs: Any + ) -> _models.Application: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Application] + + _json = self._serialize.body(parameters, 'Application') + + request = build_create_or_update_by_id_request_initial( + application_id=application_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._create_or_update_by_id_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('Application', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('Application', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_by_id_initial.metadata = {'url': "/{applicationId}"} # type: ignore + + + @distributed_trace + def begin_create_or_update_by_id( + self, + application_id: str, + parameters: _models.Application, + **kwargs: Any + ) -> LROPoller[_models.Application]: + """Creates or updates a managed application. + + :param application_id: The fully qualified ID of the managed application, including the managed + application name and the managed application resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/Microsoft.Solutions/applications/{application-name}. + :type application_id: str + :param parameters: Parameters supplied to the create or update a managed application. + :type parameters: ~azure.mgmt.managedapplication.v2018_06_01.models.Application + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Application or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.managedapplication.v2018_06_01.models.Application] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Application] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._create_or_update_by_id_initial( # type: ignore + application_id=application_id, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('Application', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update_by_id.metadata = {'url': "/{applicationId}"} # type: ignore + + def _update_by_id_initial( + self, + application_id: str, + parameters: Optional[_models.ApplicationPatchable] = None, + **kwargs: Any + ) -> _models.ApplicationPatchable: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationPatchable] + + if parameters is not None: + _json = self._serialize.body(parameters, 'ApplicationPatchable') + else: + _json = None + + request = build_update_by_id_request_initial( + application_id=application_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._update_by_id_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('ApplicationPatchable', pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize('ApplicationPatchable', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _update_by_id_initial.metadata = {'url': "/{applicationId}"} # type: ignore + + + @distributed_trace + def begin_update_by_id( + self, + application_id: str, + parameters: Optional[_models.ApplicationPatchable] = None, + **kwargs: Any + ) -> LROPoller[_models.ApplicationPatchable]: + """Updates an existing managed application. + + :param application_id: The fully qualified ID of the managed application, including the managed + application name and the managed application resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/Microsoft.Solutions/applications/{application-name}. + :type application_id: str + :param parameters: Parameters supplied to update an existing managed application. Default value + is None. + :type parameters: ~azure.mgmt.managedapplication.v2018_06_01.models.ApplicationPatchable + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ApplicationPatchable or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.managedapplication.v2018_06_01.models.ApplicationPatchable] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationPatchable] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._update_by_id_initial( # type: ignore + application_id=application_id, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('ApplicationPatchable', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_update_by_id.metadata = {'url': "/{applicationId}"} # type: ignore + + def _refresh_permissions_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + application_name: str, + **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_refresh_permissions_request_initial( + resource_group_name=resource_group_name, + application_name=application_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._refresh_permissions_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _refresh_permissions_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}/refreshPermissions"} # type: ignore + + + @distributed_trace + def begin_refresh_permissions( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + application_name: str, + **kwargs: Any + ) -> LROPoller[None]: + """Refresh Permissions for application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_name: The name of the managed application. + :type application_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._refresh_permissions_initial( # type: ignore + resource_group_name=resource_group_name, + application_name=application_name, + api_version=api_version, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'location'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_refresh_permissions.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}/refreshPermissions"} # type: ignore + + def _update_access_initial( + self, + resource_group_name: str, + application_name: str, + parameters: _models.UpdateAccessDefinition, + **kwargs: Any + ) -> Optional[_models.UpdateAccessDefinition]: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.UpdateAccessDefinition]] + + _json = self._serialize.body(parameters, 'UpdateAccessDefinition') + + request = build_update_access_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + application_name=application_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._update_access_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 202: + deserialized = self._deserialize('UpdateAccessDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _update_access_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}/updateAccess"} # type: ignore + + + @distributed_trace + def begin_update_access( + self, + resource_group_name: str, + application_name: str, + parameters: _models.UpdateAccessDefinition, + **kwargs: Any + ) -> LROPoller[_models.UpdateAccessDefinition]: + """Update access for application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_name: The name of the managed application. + :type application_name: str + :param parameters: Request body parameters to update access. + :type parameters: ~azure.mgmt.managedapplication.v2018_06_01.models.UpdateAccessDefinition + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either UpdateAccessDefinition or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.managedapplication.v2018_06_01.models.UpdateAccessDefinition] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.UpdateAccessDefinition] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._update_access_initial( # type: ignore + resource_group_name=resource_group_name, + application_name=application_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('UpdateAccessDefinition', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'location'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_update_access.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}/updateAccess"} # type: ignore + + @distributed_trace + def list_tokens( + self, + resource_group_name: str, + application_name: str, + parameters: _models.ListTokenRequest, + **kwargs: Any + ) -> _models.ManagedIdentityTokenResult: + """List tokens for application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_name: The name of the managed application. + :type application_name: str + :param parameters: Request body parameters to list tokens. + :type parameters: ~azure.mgmt.managedapplication.v2018_06_01.models.ListTokenRequest + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ManagedIdentityTokenResult, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2018_06_01.models.ManagedIdentityTokenResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ManagedIdentityTokenResult] + + _json = self._serialize.body(parameters, 'ListTokenRequest') + + request = build_list_tokens_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + application_name=application_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.list_tokens.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ManagedIdentityTokenResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_tokens.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}/listTokens"} # type: ignore + diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_06_01/operations/_jit_requests_operations.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_06_01/operations/_jit_requests_operations.py new file mode 100644 index 000000000000..6fe4ea7d57bd --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_06_01/operations/_jit_requests_operations.py @@ -0,0 +1,736 @@ +# 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, Union, cast + +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.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from .._vendor import MixinABC, _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_request( + resource_group_name: str, + jit_request_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/jitRequests/{jitRequestName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "jitRequestName": _SERIALIZER.url("jit_request_name", jit_request_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_create_or_update_request_initial( + resource_group_name: str, + jit_request_name: str, + subscription_id: str, + *, + json: Optional[_models.JitRequestDefinition] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/jitRequests/{jitRequestName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "jitRequestName": _SERIALIZER.url("jit_request_name", jit_request_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_update_request( + resource_group_name: str, + jit_request_name: str, + subscription_id: str, + *, + json: Optional[_models.JitRequestPatchable] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/jitRequests/{jitRequestName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "jitRequestName": _SERIALIZER.url("jit_request_name", jit_request_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request( + resource_group_name: str, + jit_request_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/jitRequests/{jitRequestName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "jitRequestName": _SERIALIZER.url("jit_request_name", jit_request_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_list_by_subscription_request( + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Solutions/jitRequests") + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_list_by_resource_group_request( + resource_group_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/jitRequests") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + +class JitRequestsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.managedapplication.v2018_06_01.ApplicationClient`'s + :attr:`jit_requests` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + + @distributed_trace + def get( + self, + resource_group_name: str, + jit_request_name: str, + **kwargs: Any + ) -> Optional[_models.JitRequestDefinition]: + """Gets the JIT request. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param jit_request_name: The name of the JIT request. + :type jit_request_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JitRequestDefinition, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2018_06_01.models.JitRequestDefinition or None + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.JitRequestDefinition]] + + + request = build_get_request( + resource_group_name=resource_group_name, + jit_request_name=jit_request_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('JitRequestDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/jitRequests/{jitRequestName}"} # type: ignore + + + def _create_or_update_initial( + self, + resource_group_name: str, + jit_request_name: str, + parameters: _models.JitRequestDefinition, + **kwargs: Any + ) -> _models.JitRequestDefinition: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.JitRequestDefinition] + + _json = self._serialize.body(parameters, 'JitRequestDefinition') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + jit_request_name=jit_request_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('JitRequestDefinition', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('JitRequestDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/jitRequests/{jitRequestName}"} # type: ignore + + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + jit_request_name: str, + parameters: _models.JitRequestDefinition, + **kwargs: Any + ) -> LROPoller[_models.JitRequestDefinition]: + """Creates or updates the JIT request. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param jit_request_name: The name of the JIT request. + :type jit_request_name: str + :param parameters: Parameters supplied to the update JIT request. + :type parameters: ~azure.mgmt.managedapplication.v2018_06_01.models.JitRequestDefinition + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either JitRequestDefinition or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.managedapplication.v2018_06_01.models.JitRequestDefinition] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.JitRequestDefinition] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._create_or_update_initial( # type: ignore + resource_group_name=resource_group_name, + jit_request_name=jit_request_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('JitRequestDefinition', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/jitRequests/{jitRequestName}"} # type: ignore + + @distributed_trace + def update( + self, + resource_group_name: str, + jit_request_name: str, + parameters: _models.JitRequestPatchable, + **kwargs: Any + ) -> _models.JitRequestDefinition: + """Updates the JIT request. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param jit_request_name: The name of the JIT request. + :type jit_request_name: str + :param parameters: Parameters supplied to the update JIT request. + :type parameters: ~azure.mgmt.managedapplication.v2018_06_01.models.JitRequestPatchable + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JitRequestDefinition, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2018_06_01.models.JitRequestDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.JitRequestDefinition] + + _json = self._serialize.body(parameters, 'JitRequestPatchable') + + request = build_update_request( + resource_group_name=resource_group_name, + jit_request_name=jit_request_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('JitRequestDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/jitRequests/{jitRequestName}"} # type: ignore + + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + jit_request_name: str, + **kwargs: Any + ) -> None: + """Deletes the JIT request. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param jit_request_name: The name of the JIT request. + :type jit_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 + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_request( + resource_group_name=resource_group_name, + jit_request_name=jit_request_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/jitRequests/{jitRequestName}"} # type: ignore + + + @distributed_trace + def list_by_subscription( + self, + **kwargs: Any + ) -> _models.JitRequestDefinitionListResult: + """Lists all JIT requests within the subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JitRequestDefinitionListResult, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2018_06_01.models.JitRequestDefinitionListResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.JitRequestDefinitionListResult] + + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('JitRequestDefinitionListResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Solutions/jitRequests"} # type: ignore + + + @distributed_trace + def list_by_resource_group( + self, + resource_group_name: str, + **kwargs: Any + ) -> _models.JitRequestDefinitionListResult: + """Retrieves all JIT requests within the 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: JitRequestDefinitionListResult, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2018_06_01.models.JitRequestDefinitionListResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.JitRequestDefinitionListResult] + + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_resource_group.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('JitRequestDefinitionListResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/jitRequests"} # type: ignore + diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_06_01/operations/_patch.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_06_01/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_06_01/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_06_01/py.typed b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_06_01/py.typed new file mode 100644 index 000000000000..e5aff4f83af8 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_06_01/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_09_01_preview/__init__.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_09_01_preview/__init__.py new file mode 100644 index 000000000000..2e61ca12e56a --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_09_01_preview/__init__.py @@ -0,0 +1,23 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._application_client import ApplicationClient +from ._version import VERSION + +__version__ = VERSION + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk +__all__ = ['ApplicationClient'] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_09_01_preview/_application_client.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_09_01_preview/_application_client.py new file mode 100644 index 000000000000..81f27e33227b --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_09_01_preview/_application_client.py @@ -0,0 +1,112 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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 ApplicationClientConfiguration +from .operations import ApplicationClientOperationsMixin, ApplicationDefinitionsOperations, ApplicationsOperations, JitRequestsOperations + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential + +class ApplicationClient(ApplicationClientOperationsMixin): + """ARM applications. + + :ivar applications: ApplicationsOperations operations + :vartype applications: + azure.mgmt.managedapplication.v2018_09_01_preview.operations.ApplicationsOperations + :ivar application_definitions: ApplicationDefinitionsOperations operations + :vartype application_definitions: + azure.mgmt.managedapplication.v2018_09_01_preview.operations.ApplicationDefinitionsOperations + :ivar jit_requests: JitRequestsOperations operations + :vartype jit_requests: + azure.mgmt.managedapplication.v2018_09_01_preview.operations.JitRequestsOperations + :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 "2018-09-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + """ + + def __init__( + self, + credential: "TokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = ApplicationClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.applications = ApplicationsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.application_definitions = ApplicationDefinitionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.jit_requests = JitRequestsOperations( + 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: () -> ApplicationClient + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (Any) -> None + self._client.__exit__(*exc_details) diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_09_01_preview/_configuration.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_09_01_preview/_configuration.py new file mode 100644 index 000000000000..ec45393eb8e4 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_09_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 ApplicationClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes + """Configuration for ApplicationClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials.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: "TokenCredential", + subscription_id: str, + **kwargs: Any + ) -> None: + super(ApplicationClientConfiguration, 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.") + + 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-managedapplication/{}'.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/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_09_01_preview/_metadata.json b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_09_01_preview/_metadata.json new file mode 100644 index 000000000000..231f636ebbcc --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_09_01_preview/_metadata.json @@ -0,0 +1,123 @@ +{ + "chosen_version": "2018-09-01-preview", + "total_api_version_list": ["2018-09-01-preview"], + "client": { + "name": "ApplicationClient", + "filename": "_application_client", + "description": "ARM applications.", + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": null, + "azure_arm": true, + "has_lro_operations": true, + "client_side_validation": false, + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ApplicationClientConfiguration\"], \"._operations_mixin\": [\"ApplicationClientOperationsMixin\"]}, \"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\": [\"ApplicationClientConfiguration\"], \"._operations_mixin\": [\"ApplicationClientOperationsMixin\"]}, \"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": { + "applications": "ApplicationsOperations", + "application_definitions": "ApplicationDefinitionsOperations", + "jit_requests": "JitRequestsOperations" + }, + "operation_mixins": { + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Iterable\"]}, \"azurecore\": {\"azure.core.paging\": [\"ItemPaged\"]}}, \"regular\": {\"local\": {\".\": [[\"models\", \"_models\"]]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"AsyncIterable\"]}, \"azurecore\": {\"azure.core.async_paging\": [\"AsyncItemPaged\"]}}, \"regular\": {\"local\": {\"..\": [[\"models\", \"_models\"]]}}}", + "operations": { + "list_operations" : { + "sync": { + "signature": "def list_operations(\n self,\n **kwargs # type: Any\n):\n # type: (...) -\u003e Iterable[_models.OperationListResult]\n", + "doc": "\"\"\"Lists all of the available Microsoft.Solutions REST API operations.\n\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: An iterator like instance of either OperationListResult or the result of cls(response)\n:rtype:\n ~azure.core.paging.ItemPaged[~azure.mgmt.managedapplication.v2018_09_01_preview.models.OperationListResult]\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"", + "call": "**kwargs" + }, + "async": { + "coroutine": false, + "signature": "def list_operations(\n self,\n **kwargs: Any\n) -\u003e AsyncIterable[_models.OperationListResult]:\n", + "doc": "\"\"\"Lists all of the available Microsoft.Solutions REST API operations.\n\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: An iterator like instance of either OperationListResult or the result of cls(response)\n:rtype:\n ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.managedapplication.v2018_09_01_preview.models.OperationListResult]\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"", + "call": "**kwargs" + } + } + } + } +} \ No newline at end of file diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_09_01_preview/_patch.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_09_01_preview/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_09_01_preview/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_09_01_preview/_vendor.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_09_01_preview/_vendor.py new file mode 100644 index 000000000000..bf1845cabc0f --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_09_01_preview/_vendor.py @@ -0,0 +1,45 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from abc import ABC +from typing import TYPE_CHECKING + +from azure.core.pipeline.transport import HttpRequest + +from ._configuration import ApplicationClientConfiguration + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from msrest import Deserializer, Serializer + + from azure.core import PipelineClient + +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) + +class MixinABC(ABC): + """DO NOT use this class. It is for internal typing use only.""" + _client: "PipelineClient" + _config: ApplicationClientConfiguration + _serialize: "Serializer" + _deserialize: "Deserializer" diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_09_01_preview/_version.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_09_01_preview/_version.py new file mode 100644 index 000000000000..e5754a47ce68 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_09_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/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_09_01_preview/aio/__init__.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_09_01_preview/aio/__init__.py new file mode 100644 index 000000000000..c90626a31421 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_09_01_preview/aio/__init__.py @@ -0,0 +1,20 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._application_client import ApplicationClient + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk +__all__ = ['ApplicationClient'] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_09_01_preview/aio/_application_client.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_09_01_preview/aio/_application_client.py new file mode 100644 index 000000000000..7416d4d9daa4 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_09_01_preview/aio/_application_client.py @@ -0,0 +1,109 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# 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 ApplicationClientConfiguration +from .operations import ApplicationClientOperationsMixin, ApplicationDefinitionsOperations, ApplicationsOperations, JitRequestsOperations + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + +class ApplicationClient(ApplicationClientOperationsMixin): + """ARM applications. + + :ivar applications: ApplicationsOperations operations + :vartype applications: + azure.mgmt.managedapplication.v2018_09_01_preview.aio.operations.ApplicationsOperations + :ivar application_definitions: ApplicationDefinitionsOperations operations + :vartype application_definitions: + azure.mgmt.managedapplication.v2018_09_01_preview.aio.operations.ApplicationDefinitionsOperations + :ivar jit_requests: JitRequestsOperations operations + :vartype jit_requests: + azure.mgmt.managedapplication.v2018_09_01_preview.aio.operations.JitRequestsOperations + :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 "2018-09-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = ApplicationClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.applications = ApplicationsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.application_definitions = ApplicationDefinitionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.jit_requests = JitRequestsOperations( + 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) -> "ApplicationClient": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_09_01_preview/aio/_configuration.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_09_01_preview/aio/_configuration.py new file mode 100644 index 000000000000..1642ed9a6052 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_09_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 ApplicationClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes + """Configuration for ApplicationClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :param subscription_id: The ID of the target subscription. + :type subscription_id: str + :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, + **kwargs: Any + ) -> None: + super(ApplicationClientConfiguration, 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.") + + 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-managedapplication/{}'.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/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_09_01_preview/aio/_patch.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_09_01_preview/aio/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_09_01_preview/aio/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_09_01_preview/aio/_vendor.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_09_01_preview/aio/_vendor.py new file mode 100644 index 000000000000..da14e4f71f0e --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_09_01_preview/aio/_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 abc import ABC +from typing import TYPE_CHECKING + +from azure.core.pipeline.transport import HttpRequest + +from ._configuration import ApplicationClientConfiguration + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from msrest import Deserializer, Serializer + + from azure.core import AsyncPipelineClient + + +class MixinABC(ABC): + """DO NOT use this class. It is for internal typing use only.""" + _client: "AsyncPipelineClient" + _config: ApplicationClientConfiguration + _serialize: "Serializer" + _deserialize: "Deserializer" diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_09_01_preview/aio/operations/__init__.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_09_01_preview/aio/operations/__init__.py new file mode 100644 index 000000000000..b93ecbbe65e2 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_09_01_preview/aio/operations/__init__.py @@ -0,0 +1,24 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._application_client_operations import ApplicationClientOperationsMixin +from ._applications_operations import ApplicationsOperations +from ._application_definitions_operations import ApplicationDefinitionsOperations +from ._jit_requests_operations import JitRequestsOperations + +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk +__all__ = [ + 'ApplicationClientOperationsMixin', + 'ApplicationsOperations', + 'ApplicationDefinitionsOperations', + 'JitRequestsOperations', +] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_09_01_preview/aio/operations/_application_client_operations.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_09_01_preview/aio/operations/_application_client_operations.py new file mode 100644 index 000000000000..3b6cdac1c56a --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_09_01_preview/aio/operations/_application_client_operations.py @@ -0,0 +1,105 @@ +# 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.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._application_client_operations import build_list_operations_request +from .._vendor import MixinABC +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class ApplicationClientOperationsMixin(MixinABC): + + @distributed_trace + def list_operations( + self, + **kwargs: Any + ) -> AsyncIterable[_models.OperationListResult]: + """Lists all of the available Microsoft.Solutions REST API operations. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either OperationListResult or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.managedapplication.v2018_09_01_preview.models.OperationListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-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', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_operations_request( + api_version=api_version, + template_url=self.list_operations.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_operations_request( + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list_operations.metadata = {'url': "/providers/Microsoft.Solutions/operations"} # type: ignore diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_09_01_preview/aio/operations/_application_definitions_operations.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_09_01_preview/aio/operations/_application_definitions_operations.py new file mode 100644 index 000000000000..451ecec06011 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_09_01_preview/aio/operations/_application_definitions_operations.py @@ -0,0 +1,763 @@ +# 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.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._application_definitions_operations import build_create_or_update_by_id_request, build_create_or_update_request, build_delete_by_id_request, build_delete_request, build_get_by_id_request, build_get_request, build_list_by_resource_group_request, build_list_by_subscription_request, build_update_by_id_request, build_update_request +from .._vendor import MixinABC +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class ApplicationDefinitionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.managedapplication.v2018_09_01_preview.aio.ApplicationClient`'s + :attr:`application_definitions` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + application_definition_name: str, + **kwargs: Any + ) -> Optional[_models.ApplicationDefinition]: + """Gets the managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. + :type application_definition_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ApplicationDefinition, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2018_09_01_preview.models.ApplicationDefinition or None + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.ApplicationDefinition]] + + + request = build_get_request( + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('ApplicationDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore + + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + application_definition_name: str, + **kwargs: Any + ) -> None: + """Deletes the managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition to delete. + :type application_definition_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_request( + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore + + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + application_definition_name: str, + parameters: _models.ApplicationDefinition, + **kwargs: Any + ) -> _models.ApplicationDefinition: + """Creates or updates a managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. + :type application_definition_name: str + :param parameters: Parameters supplied to the create or update an managed application + definition. + :type parameters: + ~azure.mgmt.managedapplication.v2018_09_01_preview.models.ApplicationDefinition + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ApplicationDefinition, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2018_09_01_preview.models.ApplicationDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationDefinition] + + _json = self._serialize.body(parameters, 'ApplicationDefinition') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # 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, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('ApplicationDefinition', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('ApplicationDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore + + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + application_definition_name: str, + parameters: _models.ApplicationDefinitionPatchable, + **kwargs: Any + ) -> _models.ApplicationDefinition: + """Updates the managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. + :type application_definition_name: str + :param parameters: Parameters supplied to the update a managed application definition. + :type parameters: + ~azure.mgmt.managedapplication.v2018_09_01_preview.models.ApplicationDefinitionPatchable + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ApplicationDefinition, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2018_09_01_preview.models.ApplicationDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationDefinition] + + _json = self._serialize.body(parameters, 'ApplicationDefinitionPatchable') + + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ApplicationDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore + + + @distributed_trace + def list_by_resource_group( + self, + resource_group_name: str, + **kwargs: Any + ) -> AsyncIterable[_models.ApplicationDefinitionListResult]: + """Lists the managed application definitions in a resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ApplicationDefinitionListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.managedapplication.v2018_09_01_preview.models.ApplicationDefinitionListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationDefinitionListResult] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_resource_group.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ApplicationDefinitionListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions"} # type: ignore + + @distributed_trace + def list_by_subscription( + self, + **kwargs: Any + ) -> AsyncIterable[_models.ApplicationDefinitionListResult]: + """Lists the managed application definitions in a subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ApplicationDefinitionListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.managedapplication.v2018_09_01_preview.models.ApplicationDefinitionListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationDefinitionListResult] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ApplicationDefinitionListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Solutions/applicationDefinitions"} # type: ignore + + @distributed_trace_async + async def get_by_id( + self, + resource_group_name: str, + application_definition_name: str, + **kwargs: Any + ) -> Optional[_models.ApplicationDefinition]: + """Gets the managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. + :type application_definition_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ApplicationDefinition, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2018_09_01_preview.models.ApplicationDefinition or None + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.ApplicationDefinition]] + + + request = build_get_by_id_request( + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_by_id.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('ApplicationDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_by_id.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore + + + @distributed_trace_async + async def delete_by_id( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + application_definition_name: str, + **kwargs: Any + ) -> None: + """Deletes the managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. + :type application_definition_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_by_id_request( + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete_by_id.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete_by_id.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore + + + @distributed_trace_async + async def create_or_update_by_id( + self, + resource_group_name: str, + application_definition_name: str, + parameters: _models.ApplicationDefinition, + **kwargs: Any + ) -> _models.ApplicationDefinition: + """Creates or updates a managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. + :type application_definition_name: str + :param parameters: Parameters supplied to the create or update a managed application + definition. + :type parameters: + ~azure.mgmt.managedapplication.v2018_09_01_preview.models.ApplicationDefinition + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ApplicationDefinition, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2018_09_01_preview.models.ApplicationDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationDefinition] + + _json = self._serialize.body(parameters, 'ApplicationDefinition') + + request = build_create_or_update_by_id_request( + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + 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'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # 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, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('ApplicationDefinition', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('ApplicationDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_or_update_by_id.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore + + + @distributed_trace_async + async def update_by_id( + self, + resource_group_name: str, + application_definition_name: str, + parameters: _models.ApplicationDefinitionPatchable, + **kwargs: Any + ) -> _models.ApplicationDefinition: + """Updates the managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. + :type application_definition_name: str + :param parameters: Parameters supplied to the update a managed application definition. + :type parameters: + ~azure.mgmt.managedapplication.v2018_09_01_preview.models.ApplicationDefinitionPatchable + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ApplicationDefinition, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2018_09_01_preview.models.ApplicationDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationDefinition] + + _json = self._serialize.body(parameters, 'ApplicationDefinitionPatchable') + + request = build_update_by_id_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.update_by_id.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ApplicationDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + update_by_id.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore + diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_09_01_preview/aio/operations/_applications_operations.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_09_01_preview/aio/operations/_applications_operations.py new file mode 100644 index 000000000000..b49b4b53d3ab --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_09_01_preview/aio/operations/_applications_operations.py @@ -0,0 +1,1484 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union, cast + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._applications_operations import build_create_or_update_by_id_request_initial, build_create_or_update_request_initial, build_delete_by_id_request_initial, build_delete_request_initial, build_get_by_id_request, build_get_request, build_list_by_resource_group_request, build_list_by_subscription_request, build_list_tokens_request, build_refresh_permissions_request_initial, build_update_access_request_initial, build_update_by_id_request_initial, build_update_request_initial +from .._vendor import MixinABC +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class ApplicationsOperations: # pylint: disable=too-many-public-methods + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.managedapplication.v2018_09_01_preview.aio.ApplicationClient`'s + :attr:`applications` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + application_name: str, + **kwargs: Any + ) -> Optional[_models.Application]: + """Gets the managed application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_name: The name of the managed application. + :type application_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Application, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2018_09_01_preview.models.Application or None + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.Application]] + + + request = build_get_request( + resource_group_name=resource_group_name, + application_name=application_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('Application', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}"} # type: ignore + + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + application_name: str, + **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + application_name=application_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}"} # type: ignore + + + @distributed_trace_async + async def begin_delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + application_name: str, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes the managed application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_name: The name of the managed application. + :type application_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._delete_initial( # type: ignore + resource_group_name=resource_group_name, + application_name=application_name, + api_version=api_version, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}"} # type: ignore + + async def _create_or_update_initial( + self, + resource_group_name: str, + application_name: str, + parameters: _models.Application, + **kwargs: Any + ) -> _models.Application: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Application] + + _json = self._serialize.body(parameters, 'Application') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + application_name=application_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('Application', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('Application', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}"} # type: ignore + + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + application_name: str, + parameters: _models.Application, + **kwargs: Any + ) -> AsyncLROPoller[_models.Application]: + """Creates or updates a managed application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_name: The name of the managed application. + :type application_name: str + :param parameters: Parameters supplied to the create or update a managed application. + :type parameters: ~azure.mgmt.managedapplication.v2018_09_01_preview.models.Application + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either Application or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.managedapplication.v2018_09_01_preview.models.Application] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Application] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._create_or_update_initial( # type: ignore + resource_group_name=resource_group_name, + application_name=application_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('Application', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}"} # type: ignore + + async def _update_initial( + self, + resource_group_name: str, + application_name: str, + parameters: Optional[_models.ApplicationPatchable] = None, + **kwargs: Any + ) -> _models.ApplicationPatchable: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationPatchable] + + if parameters is not None: + _json = self._serialize.body(parameters, 'ApplicationPatchable') + else: + _json = None + + request = build_update_request_initial( + resource_group_name=resource_group_name, + application_name=application_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('ApplicationPatchable', pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize('ApplicationPatchable', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}"} # type: ignore + + + @distributed_trace_async + async def begin_update( + self, + resource_group_name: str, + application_name: str, + parameters: Optional[_models.ApplicationPatchable] = None, + **kwargs: Any + ) -> AsyncLROPoller[_models.ApplicationPatchable]: + """Updates an existing managed application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_name: The name of the managed application. + :type application_name: str + :param parameters: Parameters supplied to update an existing managed application. Default value + is None. + :type parameters: + ~azure.mgmt.managedapplication.v2018_09_01_preview.models.ApplicationPatchable + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ApplicationPatchable or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.managedapplication.v2018_09_01_preview.models.ApplicationPatchable] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationPatchable] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._update_initial( # type: ignore + resource_group_name=resource_group_name, + application_name=application_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('ApplicationPatchable', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}"} # type: ignore + + @distributed_trace + def list_by_resource_group( + self, + resource_group_name: str, + **kwargs: Any + ) -> AsyncIterable[_models.ApplicationListResult]: + """Lists all the applications within a resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ApplicationListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.managedapplication.v2018_09_01_preview.models.ApplicationListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationListResult] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_resource_group.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ApplicationListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications"} # type: ignore + + @distributed_trace + def list_by_subscription( + self, + **kwargs: Any + ) -> AsyncIterable[_models.ApplicationListResult]: + """Lists all the applications within a subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ApplicationListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.managedapplication.v2018_09_01_preview.models.ApplicationListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationListResult] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ApplicationListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Solutions/applications"} # type: ignore + + @distributed_trace_async + async def get_by_id( + self, + application_id: str, + **kwargs: Any + ) -> Optional[_models.Application]: + """Gets the managed application. + + :param application_id: The fully qualified ID of the managed application, including the managed + application name and the managed application resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/Microsoft.Solutions/applications/{application-name}. + :type application_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Application, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2018_09_01_preview.models.Application or None + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.Application]] + + + request = build_get_by_id_request( + application_id=application_id, + api_version=api_version, + template_url=self.get_by_id.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('Application', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_by_id.metadata = {'url': "/{applicationId}"} # type: ignore + + + async def _delete_by_id_initial( # pylint: disable=inconsistent-return-statements + self, + application_id: str, + **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_by_id_request_initial( + application_id=application_id, + api_version=api_version, + template_url=self._delete_by_id_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_by_id_initial.metadata = {'url': "/{applicationId}"} # type: ignore + + + @distributed_trace_async + async def begin_delete_by_id( # pylint: disable=inconsistent-return-statements + self, + application_id: str, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes the managed application. + + :param application_id: The fully qualified ID of the managed application, including the managed + application name and the managed application resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/Microsoft.Solutions/applications/{application-name}. + :type application_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._delete_by_id_initial( # type: ignore + application_id=application_id, + api_version=api_version, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete_by_id.metadata = {'url': "/{applicationId}"} # type: ignore + + async def _create_or_update_by_id_initial( + self, + application_id: str, + parameters: _models.Application, + **kwargs: Any + ) -> _models.Application: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Application] + + _json = self._serialize.body(parameters, 'Application') + + request = build_create_or_update_by_id_request_initial( + application_id=application_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._create_or_update_by_id_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('Application', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('Application', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_by_id_initial.metadata = {'url': "/{applicationId}"} # type: ignore + + + @distributed_trace_async + async def begin_create_or_update_by_id( + self, + application_id: str, + parameters: _models.Application, + **kwargs: Any + ) -> AsyncLROPoller[_models.Application]: + """Creates or updates a managed application. + + :param application_id: The fully qualified ID of the managed application, including the managed + application name and the managed application resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/Microsoft.Solutions/applications/{application-name}. + :type application_id: str + :param parameters: Parameters supplied to the create or update a managed application. + :type parameters: ~azure.mgmt.managedapplication.v2018_09_01_preview.models.Application + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either Application or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.managedapplication.v2018_09_01_preview.models.Application] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Application] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._create_or_update_by_id_initial( # type: ignore + application_id=application_id, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('Application', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update_by_id.metadata = {'url': "/{applicationId}"} # type: ignore + + async def _update_by_id_initial( + self, + application_id: str, + parameters: Optional[_models.ApplicationPatchable] = None, + **kwargs: Any + ) -> _models.ApplicationPatchable: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationPatchable] + + if parameters is not None: + _json = self._serialize.body(parameters, 'ApplicationPatchable') + else: + _json = None + + request = build_update_by_id_request_initial( + application_id=application_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._update_by_id_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('ApplicationPatchable', pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize('ApplicationPatchable', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _update_by_id_initial.metadata = {'url': "/{applicationId}"} # type: ignore + + + @distributed_trace_async + async def begin_update_by_id( + self, + application_id: str, + parameters: Optional[_models.ApplicationPatchable] = None, + **kwargs: Any + ) -> AsyncLROPoller[_models.ApplicationPatchable]: + """Updates an existing managed application. + + :param application_id: The fully qualified ID of the managed application, including the managed + application name and the managed application resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/Microsoft.Solutions/applications/{application-name}. + :type application_id: str + :param parameters: Parameters supplied to update an existing managed application. Default value + is None. + :type parameters: + ~azure.mgmt.managedapplication.v2018_09_01_preview.models.ApplicationPatchable + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ApplicationPatchable or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.managedapplication.v2018_09_01_preview.models.ApplicationPatchable] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationPatchable] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._update_by_id_initial( # type: ignore + application_id=application_id, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('ApplicationPatchable', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_update_by_id.metadata = {'url': "/{applicationId}"} # type: ignore + + async def _refresh_permissions_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + application_name: str, + **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_refresh_permissions_request_initial( + resource_group_name=resource_group_name, + application_name=application_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._refresh_permissions_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _refresh_permissions_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}/refreshPermissions"} # type: ignore + + + @distributed_trace_async + async def begin_refresh_permissions( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + application_name: str, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Refresh Permissions for application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_name: The name of the managed application. + :type application_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._refresh_permissions_initial( # type: ignore + resource_group_name=resource_group_name, + application_name=application_name, + api_version=api_version, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'location'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_refresh_permissions.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}/refreshPermissions"} # type: ignore + + async def _update_access_initial( + self, + resource_group_name: str, + application_name: str, + parameters: _models.UpdateAccessDefinition, + **kwargs: Any + ) -> Optional[_models.UpdateAccessDefinition]: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.UpdateAccessDefinition]] + + _json = self._serialize.body(parameters, 'UpdateAccessDefinition') + + request = build_update_access_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + application_name=application_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._update_access_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 202: + deserialized = self._deserialize('UpdateAccessDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _update_access_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}/updateAccess"} # type: ignore + + + @distributed_trace_async + async def begin_update_access( + self, + resource_group_name: str, + application_name: str, + parameters: _models.UpdateAccessDefinition, + **kwargs: Any + ) -> AsyncLROPoller[_models.UpdateAccessDefinition]: + """Update access for application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_name: The name of the managed application. + :type application_name: str + :param parameters: Request body parameters to update access. + :type parameters: + ~azure.mgmt.managedapplication.v2018_09_01_preview.models.UpdateAccessDefinition + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either UpdateAccessDefinition or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.managedapplication.v2018_09_01_preview.models.UpdateAccessDefinition] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.UpdateAccessDefinition] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._update_access_initial( # type: ignore + resource_group_name=resource_group_name, + application_name=application_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('UpdateAccessDefinition', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'location'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_update_access.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}/updateAccess"} # type: ignore + + @distributed_trace_async + async def list_tokens( + self, + resource_group_name: str, + application_name: str, + parameters: _models.ListTokenRequest, + **kwargs: Any + ) -> _models.ManagedIdentityTokenResult: + """List tokens for application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_name: The name of the managed application. + :type application_name: str + :param parameters: Request body parameters to list tokens. + :type parameters: ~azure.mgmt.managedapplication.v2018_09_01_preview.models.ListTokenRequest + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ManagedIdentityTokenResult, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2018_09_01_preview.models.ManagedIdentityTokenResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ManagedIdentityTokenResult] + + _json = self._serialize.body(parameters, 'ListTokenRequest') + + request = build_list_tokens_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + application_name=application_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.list_tokens.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ManagedIdentityTokenResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_tokens.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}/listTokens"} # type: ignore + diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_09_01_preview/aio/operations/_jit_requests_operations.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_09_01_preview/aio/operations/_jit_requests_operations.py new file mode 100644 index 000000000000..47e2976e7dd3 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_09_01_preview/aio/operations/_jit_requests_operations.py @@ -0,0 +1,505 @@ +# 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, Union, cast + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._jit_requests_operations import build_create_or_update_request_initial, build_delete_request, build_get_request, build_list_by_resource_group_request, build_list_by_subscription_request, build_update_request +from .._vendor import MixinABC +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class JitRequestsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.managedapplication.v2018_09_01_preview.aio.ApplicationClient`'s + :attr:`jit_requests` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + jit_request_name: str, + **kwargs: Any + ) -> Optional[_models.JitRequestDefinition]: + """Gets the JIT request. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param jit_request_name: The name of the JIT request. + :type jit_request_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JitRequestDefinition, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2018_09_01_preview.models.JitRequestDefinition or None + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.JitRequestDefinition]] + + + request = build_get_request( + resource_group_name=resource_group_name, + jit_request_name=jit_request_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('JitRequestDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/jitRequests/{jitRequestName}"} # type: ignore + + + async def _create_or_update_initial( + self, + resource_group_name: str, + jit_request_name: str, + parameters: _models.JitRequestDefinition, + **kwargs: Any + ) -> _models.JitRequestDefinition: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.JitRequestDefinition] + + _json = self._serialize.body(parameters, 'JitRequestDefinition') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + jit_request_name=jit_request_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('JitRequestDefinition', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('JitRequestDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/jitRequests/{jitRequestName}"} # type: ignore + + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + jit_request_name: str, + parameters: _models.JitRequestDefinition, + **kwargs: Any + ) -> AsyncLROPoller[_models.JitRequestDefinition]: + """Creates or updates the JIT request. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param jit_request_name: The name of the JIT request. + :type jit_request_name: str + :param parameters: Parameters supplied to the update JIT request. + :type parameters: + ~azure.mgmt.managedapplication.v2018_09_01_preview.models.JitRequestDefinition + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either JitRequestDefinition or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.managedapplication.v2018_09_01_preview.models.JitRequestDefinition] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.JitRequestDefinition] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._create_or_update_initial( # type: ignore + resource_group_name=resource_group_name, + jit_request_name=jit_request_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('JitRequestDefinition', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/jitRequests/{jitRequestName}"} # type: ignore + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + jit_request_name: str, + parameters: _models.JitRequestPatchable, + **kwargs: Any + ) -> _models.JitRequestDefinition: + """Updates the JIT request. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param jit_request_name: The name of the JIT request. + :type jit_request_name: str + :param parameters: Parameters supplied to the update JIT request. + :type parameters: ~azure.mgmt.managedapplication.v2018_09_01_preview.models.JitRequestPatchable + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JitRequestDefinition, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2018_09_01_preview.models.JitRequestDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.JitRequestDefinition] + + _json = self._serialize.body(parameters, 'JitRequestPatchable') + + request = build_update_request( + resource_group_name=resource_group_name, + jit_request_name=jit_request_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('JitRequestDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/jitRequests/{jitRequestName}"} # type: ignore + + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + jit_request_name: str, + **kwargs: Any + ) -> None: + """Deletes the JIT request. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param jit_request_name: The name of the JIT request. + :type jit_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 + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_request( + resource_group_name=resource_group_name, + jit_request_name=jit_request_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/jitRequests/{jitRequestName}"} # type: ignore + + + @distributed_trace_async + async def list_by_subscription( + self, + **kwargs: Any + ) -> _models.JitRequestDefinitionListResult: + """Lists all JIT requests within the subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JitRequestDefinitionListResult, or the result of cls(response) + :rtype: + ~azure.mgmt.managedapplication.v2018_09_01_preview.models.JitRequestDefinitionListResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.JitRequestDefinitionListResult] + + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('JitRequestDefinitionListResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Solutions/jitRequests"} # type: ignore + + + @distributed_trace_async + async def list_by_resource_group( + self, + resource_group_name: str, + **kwargs: Any + ) -> _models.JitRequestDefinitionListResult: + """Lists all JIT requests within the 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: JitRequestDefinitionListResult, or the result of cls(response) + :rtype: + ~azure.mgmt.managedapplication.v2018_09_01_preview.models.JitRequestDefinitionListResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.JitRequestDefinitionListResult] + + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_resource_group.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('JitRequestDefinitionListResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/jitRequests"} # type: ignore + diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_09_01_preview/aio/operations/_patch.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_09_01_preview/aio/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_09_01_preview/aio/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_09_01_preview/models/__init__.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_09_01_preview/models/__init__.py new file mode 100644 index 000000000000..0c0a1a89e8e1 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_09_01_preview/models/__init__.py @@ -0,0 +1,131 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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 Application +from ._models_py3 import ApplicationArtifact +from ._models_py3 import ApplicationAuthorization +from ._models_py3 import ApplicationBillingDetailsDefinition +from ._models_py3 import ApplicationClientDetails +from ._models_py3 import ApplicationDefinition +from ._models_py3 import ApplicationDefinitionArtifact +from ._models_py3 import ApplicationDefinitionListResult +from ._models_py3 import ApplicationDefinitionPatchable +from ._models_py3 import ApplicationJitAccessPolicy +from ._models_py3 import ApplicationListResult +from ._models_py3 import ApplicationPackageContact +from ._models_py3 import ApplicationPackageSupportUrls +from ._models_py3 import ApplicationPatchable +from ._models_py3 import ApplicationPolicy +from ._models_py3 import ApplicationPropertiesPatchable +from ._models_py3 import ErrorAdditionalInfo +from ._models_py3 import ErrorDetail +from ._models_py3 import ErrorResponse +from ._models_py3 import GenericResource +from ._models_py3 import Identity +from ._models_py3 import JitApproverDefinition +from ._models_py3 import JitAuthorizationPolicies +from ._models_py3 import JitRequestDefinition +from ._models_py3 import JitRequestDefinitionListResult +from ._models_py3 import JitRequestMetadata +from ._models_py3 import JitRequestPatchable +from ._models_py3 import JitSchedulingPolicy +from ._models_py3 import ListTokenRequest +from ._models_py3 import ManagedIdentityToken +from ._models_py3 import ManagedIdentityTokenResult +from ._models_py3 import Operation +from ._models_py3 import OperationAutoGenerated +from ._models_py3 import OperationDisplay +from ._models_py3 import OperationDisplayAutoGenerated +from ._models_py3 import OperationListResult +from ._models_py3 import Plan +from ._models_py3 import PlanPatchable +from ._models_py3 import Resource +from ._models_py3 import Sku +from ._models_py3 import UpdateAccessDefinition +from ._models_py3 import UserAssignedResourceIdentity + + +from ._application_client_enums import ( + ActionType, + ApplicationArtifactName, + ApplicationArtifactType, + ApplicationDefinitionArtifactName, + ApplicationLockLevel, + JitApprovalMode, + JitApproverType, + JitRequestState, + JitSchedulingType, + Origin, + ProvisioningState, + ResourceIdentityType, + Status, + Substatus, +) +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk +__all__ = [ + 'Application', + 'ApplicationArtifact', + 'ApplicationAuthorization', + 'ApplicationBillingDetailsDefinition', + 'ApplicationClientDetails', + 'ApplicationDefinition', + 'ApplicationDefinitionArtifact', + 'ApplicationDefinitionListResult', + 'ApplicationDefinitionPatchable', + 'ApplicationJitAccessPolicy', + 'ApplicationListResult', + 'ApplicationPackageContact', + 'ApplicationPackageSupportUrls', + 'ApplicationPatchable', + 'ApplicationPolicy', + 'ApplicationPropertiesPatchable', + 'ErrorAdditionalInfo', + 'ErrorDetail', + 'ErrorResponse', + 'GenericResource', + 'Identity', + 'JitApproverDefinition', + 'JitAuthorizationPolicies', + 'JitRequestDefinition', + 'JitRequestDefinitionListResult', + 'JitRequestMetadata', + 'JitRequestPatchable', + 'JitSchedulingPolicy', + 'ListTokenRequest', + 'ManagedIdentityToken', + 'ManagedIdentityTokenResult', + 'Operation', + 'OperationAutoGenerated', + 'OperationDisplay', + 'OperationDisplayAutoGenerated', + 'OperationListResult', + 'Plan', + 'PlanPatchable', + 'Resource', + 'Sku', + 'UpdateAccessDefinition', + 'UserAssignedResourceIdentity', + 'ActionType', + 'ApplicationArtifactName', + 'ApplicationArtifactType', + 'ApplicationDefinitionArtifactName', + 'ApplicationLockLevel', + 'JitApprovalMode', + 'JitApproverType', + 'JitRequestState', + 'JitSchedulingType', + 'Origin', + 'ProvisioningState', + 'ResourceIdentityType', + 'Status', + 'Substatus', +] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_09_01_preview/models/_application_client_enums.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_09_01_preview/models/_application_client_enums.py new file mode 100644 index 000000000000..cdab45e81a27 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_09_01_preview/models/_application_client_enums.py @@ -0,0 +1,141 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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 azure.core import CaseInsensitiveEnumMeta + + +class ActionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. + """ + + INTERNAL = "Internal" + +class ApplicationArtifactName(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The managed application artifact name. + """ + + NOT_SPECIFIED = "NotSpecified" + VIEW_DEFINITION = "ViewDefinition" + AUTHORIZATIONS = "Authorizations" + CUSTOM_ROLE_DEFINITION = "CustomRoleDefinition" + +class ApplicationArtifactType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The managed application artifact type. + """ + + NOT_SPECIFIED = "NotSpecified" + TEMPLATE = "Template" + CUSTOM = "Custom" + +class ApplicationDefinitionArtifactName(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The managed application artifact name. + """ + + NOT_SPECIFIED = "NotSpecified" + APPLICATION_RESOURCE_TEMPLATE = "ApplicationResourceTemplate" + CREATE_UI_DEFINITION = "CreateUiDefinition" + MAIN_TEMPLATE_PARAMETERS = "MainTemplateParameters" + +class ApplicationLockLevel(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The managed application lock level. + """ + + CAN_NOT_DELETE = "CanNotDelete" + READ_ONLY = "ReadOnly" + NONE = "None" + +class JitApprovalMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The Jit approval mode. + """ + + NOT_SPECIFIED = "NotSpecified" + AUTO_APPROVE = "AutoApprove" + MANUAL_APPROVE = "ManualApprove" + +class JitApproverType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The approver type. + """ + + USER = "user" + GROUP = "group" + +class JitRequestState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The JIT request state. + """ + + NOT_SPECIFIED = "NotSpecified" + PENDING = "Pending" + APPROVED = "Approved" + DENIED = "Denied" + FAILED = "Failed" + CANCELED = "Canceled" + EXPIRED = "Expired" + TIMEOUT = "Timeout" + +class JitSchedulingType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The JIT request scheduling type. + """ + + NOT_SPECIFIED = "NotSpecified" + ONCE = "Once" + RECURRING = "Recurring" + +class Origin(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit + logs UX. Default value is "user,system" + """ + + USER = "user" + SYSTEM = "system" + USER_SYSTEM = "user,system" + +class ProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Provisioning status of the managed application. + """ + + NOT_SPECIFIED = "NotSpecified" + ACCEPTED = "Accepted" + RUNNING = "Running" + READY = "Ready" + CREATING = "Creating" + CREATED = "Created" + DELETING = "Deleting" + DELETED = "Deleted" + CANCELED = "Canceled" + FAILED = "Failed" + SUCCEEDED = "Succeeded" + UPDATING = "Updating" + +class ResourceIdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The identity type. + """ + + SYSTEM_ASSIGNED = "SystemAssigned" + USER_ASSIGNED = "UserAssigned" + SYSTEM_ASSIGNED_USER_ASSIGNED = "SystemAssigned, UserAssigned" + NONE = "None" + +class Status(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The JIT status. + """ + + NOT_SPECIFIED = "NotSpecified" + ELEVATE = "Elevate" + REMOVE = "Remove" + +class Substatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The sub status. + """ + + NOT_SPECIFIED = "NotSpecified" + APPROVED = "Approved" + DENIED = "Denied" + FAILED = "Failed" + EXPIRED = "Expired" + TIMEOUT = "Timeout" diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_09_01_preview/models/_models_py3.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_09_01_preview/models/_models_py3.py new file mode 100644 index 000000000000..41883831c153 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_09_01_preview/models/_models_py3.py @@ -0,0 +1,2311 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for 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 Any, Dict, List, Optional, TYPE_CHECKING, Union + +from azure.core.exceptions import HttpResponseError +import msrest.serialization + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + import __init__ as _models + + +class Resource(msrest.serialization.Model): + """Resource information. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Resource ID. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar location: Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'location': {'key': 'location', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + } + + def __init__( + self, + *, + location: Optional[str] = None, + tags: Optional[Dict[str, str]] = None, + **kwargs + ): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + """ + super(Resource, self).__init__(**kwargs) + self.id = None + self.name = None + self.type = None + self.location = location + self.tags = tags + + +class GenericResource(Resource): + """Resource information. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Resource ID. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar location: Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar managed_by: ID of the resource that manages this resource. + :vartype managed_by: str + :ivar sku: The SKU of the resource. + :vartype sku: ~azure.mgmt.managedapplication.v2018_09_01_preview.models.Sku + """ + + _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'}, + 'location': {'key': 'location', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + 'managed_by': {'key': 'managedBy', 'type': 'str'}, + 'sku': {'key': 'sku', 'type': 'Sku'}, + } + + def __init__( + self, + *, + location: Optional[str] = None, + tags: Optional[Dict[str, str]] = None, + managed_by: Optional[str] = None, + sku: Optional["_models.Sku"] = None, + **kwargs + ): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword managed_by: ID of the resource that manages this resource. + :paramtype managed_by: str + :keyword sku: The SKU of the resource. + :paramtype sku: ~azure.mgmt.managedapplication.v2018_09_01_preview.models.Sku + """ + super(GenericResource, self).__init__(location=location, tags=tags, **kwargs) + self.managed_by = managed_by + self.sku = sku + + +class Application(GenericResource): + """Information about managed application. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar id: Resource ID. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar location: Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar managed_by: ID of the resource that manages this resource. + :vartype managed_by: str + :ivar sku: The SKU of the resource. + :vartype sku: ~azure.mgmt.managedapplication.v2018_09_01_preview.models.Sku + :ivar plan: The plan information. + :vartype plan: ~azure.mgmt.managedapplication.v2018_09_01_preview.models.Plan + :ivar kind: Required. The kind of the managed application. Allowed values are MarketPlace and + ServiceCatalog. + :vartype kind: str + :ivar identity: The identity of the resource. + :vartype identity: ~azure.mgmt.managedapplication.v2018_09_01_preview.models.Identity + :ivar managed_resource_group_id: The managed resource group Id. + :vartype managed_resource_group_id: str + :ivar application_definition_id: The fully qualified path of managed application definition Id. + :vartype application_definition_id: str + :ivar parameters: Name and value pairs that define the managed application parameters. It can + be a JObject or a well formed JSON string. + :vartype parameters: any + :ivar outputs: Name and value pairs that define the managed application outputs. + :vartype outputs: any + :ivar provisioning_state: The managed application provisioning state. Known values are: + "NotSpecified", "Accepted", "Running", "Ready", "Creating", "Created", "Deleting", "Deleted", + "Canceled", "Failed", "Succeeded", "Updating". + :vartype provisioning_state: str or + ~azure.mgmt.managedapplication.v2018_09_01_preview.models.ProvisioningState + :ivar billing_details: The managed application billing details. + :vartype billing_details: + ~azure.mgmt.managedapplication.v2018_09_01_preview.models.ApplicationBillingDetailsDefinition + :ivar jit_access_policy: The managed application Jit access policy. + :vartype jit_access_policy: + ~azure.mgmt.managedapplication.v2018_09_01_preview.models.ApplicationJitAccessPolicy + :ivar publisher_tenant_id: The publisher tenant Id. + :vartype publisher_tenant_id: str + :ivar authorizations: The read-only authorizations property that is retrieved from the + application package. + :vartype authorizations: + list[~azure.mgmt.managedapplication.v2018_09_01_preview.models.ApplicationAuthorization] + :ivar customer_support: The read-only customer support property that is retrieved from the + application package. + :vartype customer_support: + ~azure.mgmt.managedapplication.v2018_09_01_preview.models.ApplicationPackageContact + :ivar support_urls: The read-only support URLs property that is retrieved from the application + package. + :vartype support_urls: + ~azure.mgmt.managedapplication.v2018_09_01_preview.models.ApplicationPackageSupportUrls + :ivar artifacts: The collection of managed application artifacts. + :vartype artifacts: + list[~azure.mgmt.managedapplication.v2018_09_01_preview.models.ApplicationArtifact] + :ivar created_by: The client entity that created the JIT request. + :vartype created_by: + ~azure.mgmt.managedapplication.v2018_09_01_preview.models.ApplicationClientDetails + :ivar updated_by: The client entity that last updated the JIT request. + :vartype updated_by: + ~azure.mgmt.managedapplication.v2018_09_01_preview.models.ApplicationClientDetails + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'kind': {'required': True, 'pattern': r'^[-\w\._,\(\)]+$'}, + 'outputs': {'readonly': True}, + 'provisioning_state': {'readonly': True}, + 'billing_details': {'readonly': True}, + 'publisher_tenant_id': {'readonly': True}, + 'authorizations': {'readonly': True}, + 'customer_support': {'readonly': True}, + 'support_urls': {'readonly': True}, + 'artifacts': {'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'}, + 'location': {'key': 'location', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + 'managed_by': {'key': 'managedBy', 'type': 'str'}, + 'sku': {'key': 'sku', 'type': 'Sku'}, + 'plan': {'key': 'plan', 'type': 'Plan'}, + 'kind': {'key': 'kind', 'type': 'str'}, + 'identity': {'key': 'identity', 'type': 'Identity'}, + 'managed_resource_group_id': {'key': 'properties.managedResourceGroupId', 'type': 'str'}, + 'application_definition_id': {'key': 'properties.applicationDefinitionId', 'type': 'str'}, + 'parameters': {'key': 'properties.parameters', 'type': 'object'}, + 'outputs': {'key': 'properties.outputs', 'type': 'object'}, + 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + 'billing_details': {'key': 'properties.billingDetails', 'type': 'ApplicationBillingDetailsDefinition'}, + 'jit_access_policy': {'key': 'properties.jitAccessPolicy', 'type': 'ApplicationJitAccessPolicy'}, + 'publisher_tenant_id': {'key': 'properties.publisherTenantId', 'type': 'str'}, + 'authorizations': {'key': 'properties.authorizations', 'type': '[ApplicationAuthorization]'}, + 'customer_support': {'key': 'properties.customerSupport', 'type': 'ApplicationPackageContact'}, + 'support_urls': {'key': 'properties.supportUrls', 'type': 'ApplicationPackageSupportUrls'}, + 'artifacts': {'key': 'properties.artifacts', 'type': '[ApplicationArtifact]'}, + 'created_by': {'key': 'properties.createdBy', 'type': 'ApplicationClientDetails'}, + 'updated_by': {'key': 'properties.updatedBy', 'type': 'ApplicationClientDetails'}, + } + + def __init__( + self, + *, + kind: str, + location: Optional[str] = None, + tags: Optional[Dict[str, str]] = None, + managed_by: Optional[str] = None, + sku: Optional["_models.Sku"] = None, + plan: Optional["_models.Plan"] = None, + identity: Optional["_models.Identity"] = None, + managed_resource_group_id: Optional[str] = None, + application_definition_id: Optional[str] = None, + parameters: Optional[Any] = None, + jit_access_policy: Optional["_models.ApplicationJitAccessPolicy"] = None, + **kwargs + ): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword managed_by: ID of the resource that manages this resource. + :paramtype managed_by: str + :keyword sku: The SKU of the resource. + :paramtype sku: ~azure.mgmt.managedapplication.v2018_09_01_preview.models.Sku + :keyword plan: The plan information. + :paramtype plan: ~azure.mgmt.managedapplication.v2018_09_01_preview.models.Plan + :keyword kind: Required. The kind of the managed application. Allowed values are MarketPlace + and ServiceCatalog. + :paramtype kind: str + :keyword identity: The identity of the resource. + :paramtype identity: ~azure.mgmt.managedapplication.v2018_09_01_preview.models.Identity + :keyword managed_resource_group_id: The managed resource group Id. + :paramtype managed_resource_group_id: str + :keyword application_definition_id: The fully qualified path of managed application definition + Id. + :paramtype application_definition_id: str + :keyword parameters: Name and value pairs that define the managed application parameters. It + can be a JObject or a well formed JSON string. + :paramtype parameters: any + :keyword jit_access_policy: The managed application Jit access policy. + :paramtype jit_access_policy: + ~azure.mgmt.managedapplication.v2018_09_01_preview.models.ApplicationJitAccessPolicy + """ + super(Application, self).__init__(location=location, tags=tags, managed_by=managed_by, sku=sku, **kwargs) + self.plan = plan + self.kind = kind + self.identity = identity + self.managed_resource_group_id = managed_resource_group_id + self.application_definition_id = application_definition_id + self.parameters = parameters + self.outputs = None + self.provisioning_state = None + self.billing_details = None + self.jit_access_policy = jit_access_policy + self.publisher_tenant_id = None + self.authorizations = None + self.customer_support = None + self.support_urls = None + self.artifacts = None + self.created_by = None + self.updated_by = None + + +class ApplicationArtifact(msrest.serialization.Model): + """Managed application artifact. + + All required parameters must be populated in order to send to Azure. + + :ivar name: Required. The managed application artifact name. Known values are: "NotSpecified", + "ViewDefinition", "Authorizations", "CustomRoleDefinition". + :vartype name: str or + ~azure.mgmt.managedapplication.v2018_09_01_preview.models.ApplicationArtifactName + :ivar uri: Required. The managed application artifact blob uri. + :vartype uri: str + :ivar type: Required. The managed application artifact type. Known values are: "NotSpecified", + "Template", "Custom". + :vartype type: str or + ~azure.mgmt.managedapplication.v2018_09_01_preview.models.ApplicationArtifactType + """ + + _validation = { + 'name': {'required': True}, + 'uri': {'required': True}, + 'type': {'required': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'uri': {'key': 'uri', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + } + + def __init__( + self, + *, + name: Union[str, "_models.ApplicationArtifactName"], + uri: str, + type: Union[str, "_models.ApplicationArtifactType"], + **kwargs + ): + """ + :keyword name: Required. The managed application artifact name. Known values are: + "NotSpecified", "ViewDefinition", "Authorizations", "CustomRoleDefinition". + :paramtype name: str or + ~azure.mgmt.managedapplication.v2018_09_01_preview.models.ApplicationArtifactName + :keyword uri: Required. The managed application artifact blob uri. + :paramtype uri: str + :keyword type: Required. The managed application artifact type. Known values are: + "NotSpecified", "Template", "Custom". + :paramtype type: str or + ~azure.mgmt.managedapplication.v2018_09_01_preview.models.ApplicationArtifactType + """ + super(ApplicationArtifact, self).__init__(**kwargs) + self.name = name + self.uri = uri + self.type = type + + +class ApplicationAuthorization(msrest.serialization.Model): + """The managed application provider authorization. + + All required parameters must be populated in order to send to Azure. + + :ivar principal_id: Required. The provider's principal identifier. This is the identity that + the provider will use to call ARM to manage the managed application resources. + :vartype principal_id: str + :ivar role_definition_id: Required. The provider's role definition identifier. This role will + define all the permissions that the provider must have on the managed application's container + resource group. This role definition cannot have permission to delete the resource group. + :vartype role_definition_id: str + """ + + _validation = { + 'principal_id': {'required': True}, + 'role_definition_id': {'required': True}, + } + + _attribute_map = { + 'principal_id': {'key': 'principalId', 'type': 'str'}, + 'role_definition_id': {'key': 'roleDefinitionId', 'type': 'str'}, + } + + def __init__( + self, + *, + principal_id: str, + role_definition_id: str, + **kwargs + ): + """ + :keyword principal_id: Required. The provider's principal identifier. This is the identity that + the provider will use to call ARM to manage the managed application resources. + :paramtype principal_id: str + :keyword role_definition_id: Required. The provider's role definition identifier. This role + will define all the permissions that the provider must have on the managed application's + container resource group. This role definition cannot have permission to delete the resource + group. + :paramtype role_definition_id: str + """ + super(ApplicationAuthorization, self).__init__(**kwargs) + self.principal_id = principal_id + self.role_definition_id = role_definition_id + + +class ApplicationBillingDetailsDefinition(msrest.serialization.Model): + """Managed application billing details definition. + + :ivar resource_usage_id: The managed application resource usage Id. + :vartype resource_usage_id: str + """ + + _attribute_map = { + 'resource_usage_id': {'key': 'resourceUsageId', 'type': 'str'}, + } + + def __init__( + self, + *, + resource_usage_id: Optional[str] = None, + **kwargs + ): + """ + :keyword resource_usage_id: The managed application resource usage Id. + :paramtype resource_usage_id: str + """ + super(ApplicationBillingDetailsDefinition, self).__init__(**kwargs) + self.resource_usage_id = resource_usage_id + + +class ApplicationClientDetails(msrest.serialization.Model): + """The application client details to track the entity creating/updating the managed app resource. + + :ivar oid: The client Oid. + :vartype oid: str + :ivar puid: The client Puid. + :vartype puid: str + :ivar application_id: The client application Id. + :vartype application_id: str + """ + + _attribute_map = { + 'oid': {'key': 'oid', 'type': 'str'}, + 'puid': {'key': 'puid', 'type': 'str'}, + 'application_id': {'key': 'applicationId', 'type': 'str'}, + } + + def __init__( + self, + *, + oid: Optional[str] = None, + puid: Optional[str] = None, + application_id: Optional[str] = None, + **kwargs + ): + """ + :keyword oid: The client Oid. + :paramtype oid: str + :keyword puid: The client Puid. + :paramtype puid: str + :keyword application_id: The client application Id. + :paramtype application_id: str + """ + super(ApplicationClientDetails, self).__init__(**kwargs) + self.oid = oid + self.puid = puid + self.application_id = application_id + + +class ApplicationDefinition(GenericResource): + """Information about managed application definition. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar id: Resource ID. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar location: Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar managed_by: ID of the resource that manages this resource. + :vartype managed_by: str + :ivar sku: The SKU of the resource. + :vartype sku: ~azure.mgmt.managedapplication.v2018_09_01_preview.models.Sku + :ivar lock_level: Required. The managed application lock level. Known values are: + "CanNotDelete", "ReadOnly", "None". + :vartype lock_level: str or + ~azure.mgmt.managedapplication.v2018_09_01_preview.models.ApplicationLockLevel + :ivar display_name: The managed application definition display name. + :vartype display_name: str + :ivar is_enabled: A value indicating whether the package is enabled or not. + :vartype is_enabled: bool + :ivar authorizations: The managed application provider authorizations. + :vartype authorizations: + list[~azure.mgmt.managedapplication.v2018_09_01_preview.models.ApplicationAuthorization] + :ivar artifacts: The collection of managed application artifacts. The portal will use the files + specified as artifacts to construct the user experience of creating a managed application from + a managed application definition. + :vartype artifacts: + list[~azure.mgmt.managedapplication.v2018_09_01_preview.models.ApplicationDefinitionArtifact] + :ivar description: The managed application definition description. + :vartype description: str + :ivar package_file_uri: The managed application definition package file Uri. Use this element. + :vartype package_file_uri: str + :ivar main_template: The inline main template json which has resources to be provisioned. It + can be a JObject or well-formed JSON string. + :vartype main_template: any + :ivar create_ui_definition: The createUiDefinition json for the backing template with + Microsoft.Solutions/applications resource. It can be a JObject or well-formed JSON string. + :vartype create_ui_definition: any + :ivar policies: The managed application provider policies. + :vartype policies: + list[~azure.mgmt.managedapplication.v2018_09_01_preview.models.ApplicationPolicy] + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'lock_level': {'required': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'location': {'key': 'location', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + 'managed_by': {'key': 'managedBy', 'type': 'str'}, + 'sku': {'key': 'sku', 'type': 'Sku'}, + 'lock_level': {'key': 'properties.lockLevel', 'type': 'str'}, + 'display_name': {'key': 'properties.displayName', 'type': 'str'}, + 'is_enabled': {'key': 'properties.isEnabled', 'type': 'bool'}, + 'authorizations': {'key': 'properties.authorizations', 'type': '[ApplicationAuthorization]'}, + 'artifacts': {'key': 'properties.artifacts', 'type': '[ApplicationDefinitionArtifact]'}, + 'description': {'key': 'properties.description', 'type': 'str'}, + 'package_file_uri': {'key': 'properties.packageFileUri', 'type': 'str'}, + 'main_template': {'key': 'properties.mainTemplate', 'type': 'object'}, + 'create_ui_definition': {'key': 'properties.createUiDefinition', 'type': 'object'}, + 'policies': {'key': 'properties.policies', 'type': '[ApplicationPolicy]'}, + } + + def __init__( + self, + *, + lock_level: Union[str, "_models.ApplicationLockLevel"], + location: Optional[str] = None, + tags: Optional[Dict[str, str]] = None, + managed_by: Optional[str] = None, + sku: Optional["_models.Sku"] = None, + display_name: Optional[str] = None, + is_enabled: Optional[bool] = None, + authorizations: Optional[List["_models.ApplicationAuthorization"]] = None, + artifacts: Optional[List["_models.ApplicationDefinitionArtifact"]] = None, + description: Optional[str] = None, + package_file_uri: Optional[str] = None, + main_template: Optional[Any] = None, + create_ui_definition: Optional[Any] = None, + policies: Optional[List["_models.ApplicationPolicy"]] = None, + **kwargs + ): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword managed_by: ID of the resource that manages this resource. + :paramtype managed_by: str + :keyword sku: The SKU of the resource. + :paramtype sku: ~azure.mgmt.managedapplication.v2018_09_01_preview.models.Sku + :keyword lock_level: Required. The managed application lock level. Known values are: + "CanNotDelete", "ReadOnly", "None". + :paramtype lock_level: str or + ~azure.mgmt.managedapplication.v2018_09_01_preview.models.ApplicationLockLevel + :keyword display_name: The managed application definition display name. + :paramtype display_name: str + :keyword is_enabled: A value indicating whether the package is enabled or not. + :paramtype is_enabled: bool + :keyword authorizations: The managed application provider authorizations. + :paramtype authorizations: + list[~azure.mgmt.managedapplication.v2018_09_01_preview.models.ApplicationAuthorization] + :keyword artifacts: The collection of managed application artifacts. The portal will use the + files specified as artifacts to construct the user experience of creating a managed application + from a managed application definition. + :paramtype artifacts: + list[~azure.mgmt.managedapplication.v2018_09_01_preview.models.ApplicationDefinitionArtifact] + :keyword description: The managed application definition description. + :paramtype description: str + :keyword package_file_uri: The managed application definition package file Uri. Use this + element. + :paramtype package_file_uri: str + :keyword main_template: The inline main template json which has resources to be provisioned. It + can be a JObject or well-formed JSON string. + :paramtype main_template: any + :keyword create_ui_definition: The createUiDefinition json for the backing template with + Microsoft.Solutions/applications resource. It can be a JObject or well-formed JSON string. + :paramtype create_ui_definition: any + :keyword policies: The managed application provider policies. + :paramtype policies: + list[~azure.mgmt.managedapplication.v2018_09_01_preview.models.ApplicationPolicy] + """ + super(ApplicationDefinition, self).__init__(location=location, tags=tags, managed_by=managed_by, sku=sku, **kwargs) + self.lock_level = lock_level + self.display_name = display_name + self.is_enabled = is_enabled + self.authorizations = authorizations + self.artifacts = artifacts + self.description = description + self.package_file_uri = package_file_uri + self.main_template = main_template + self.create_ui_definition = create_ui_definition + self.policies = policies + + +class ApplicationDefinitionArtifact(msrest.serialization.Model): + """Application definition artifact. + + All required parameters must be populated in order to send to Azure. + + :ivar name: Required. The managed application definition artifact name. Known values are: + "NotSpecified", "ApplicationResourceTemplate", "CreateUiDefinition", "MainTemplateParameters". + :vartype name: str or + ~azure.mgmt.managedapplication.v2018_09_01_preview.models.ApplicationDefinitionArtifactName + :ivar uri: Required. The managed application definition artifact blob uri. + :vartype uri: str + :ivar type: Required. The managed application definition artifact type. Known values are: + "NotSpecified", "Template", "Custom". + :vartype type: str or + ~azure.mgmt.managedapplication.v2018_09_01_preview.models.ApplicationArtifactType + """ + + _validation = { + 'name': {'required': True}, + 'uri': {'required': True}, + 'type': {'required': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'uri': {'key': 'uri', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + } + + def __init__( + self, + *, + name: Union[str, "_models.ApplicationDefinitionArtifactName"], + uri: str, + type: Union[str, "_models.ApplicationArtifactType"], + **kwargs + ): + """ + :keyword name: Required. The managed application definition artifact name. Known values are: + "NotSpecified", "ApplicationResourceTemplate", "CreateUiDefinition", "MainTemplateParameters". + :paramtype name: str or + ~azure.mgmt.managedapplication.v2018_09_01_preview.models.ApplicationDefinitionArtifactName + :keyword uri: Required. The managed application definition artifact blob uri. + :paramtype uri: str + :keyword type: Required. The managed application definition artifact type. Known values are: + "NotSpecified", "Template", "Custom". + :paramtype type: str or + ~azure.mgmt.managedapplication.v2018_09_01_preview.models.ApplicationArtifactType + """ + super(ApplicationDefinitionArtifact, self).__init__(**kwargs) + self.name = name + self.uri = uri + self.type = type + + +class ApplicationDefinitionListResult(msrest.serialization.Model): + """List of managed application definitions. + + :ivar value: The array of managed application definitions. + :vartype value: + list[~azure.mgmt.managedapplication.v2018_09_01_preview.models.ApplicationDefinition] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[ApplicationDefinition]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["_models.ApplicationDefinition"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + """ + :keyword value: The array of managed application definitions. + :paramtype value: + list[~azure.mgmt.managedapplication.v2018_09_01_preview.models.ApplicationDefinition] + :keyword next_link: The URL to use for getting the next set of results. + :paramtype next_link: str + """ + super(ApplicationDefinitionListResult, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class ApplicationDefinitionPatchable(msrest.serialization.Model): + """Information about an application definition request. + + :ivar tags: A set of tags. Application definition tags. + :vartype tags: dict[str, str] + """ + + _attribute_map = { + 'tags': {'key': 'tags', 'type': '{str}'}, + } + + def __init__( + self, + *, + tags: Optional[Dict[str, str]] = None, + **kwargs + ): + """ + :keyword tags: A set of tags. Application definition tags. + :paramtype tags: dict[str, str] + """ + super(ApplicationDefinitionPatchable, self).__init__(**kwargs) + self.tags = tags + + +class ApplicationJitAccessPolicy(msrest.serialization.Model): + """Managed application Jit access policy. + + All required parameters must be populated in order to send to Azure. + + :ivar jit_access_enabled: Required. Whether the JIT access is enabled. + :vartype jit_access_enabled: bool + :ivar jit_approval_mode: JIT approval mode. Known values are: "NotSpecified", "AutoApprove", + "ManualApprove". + :vartype jit_approval_mode: str or + ~azure.mgmt.managedapplication.v2018_09_01_preview.models.JitApprovalMode + :ivar jit_approvers: The JIT approvers. + :vartype jit_approvers: + list[~azure.mgmt.managedapplication.v2018_09_01_preview.models.JitApproverDefinition] + :ivar maximum_jit_access_duration: The maximum duration JIT access is granted. This is an + ISO8601 time period value. + :vartype maximum_jit_access_duration: str + """ + + _validation = { + 'jit_access_enabled': {'required': True}, + } + + _attribute_map = { + 'jit_access_enabled': {'key': 'jitAccessEnabled', 'type': 'bool'}, + 'jit_approval_mode': {'key': 'jitApprovalMode', 'type': 'str'}, + 'jit_approvers': {'key': 'jitApprovers', 'type': '[JitApproverDefinition]'}, + 'maximum_jit_access_duration': {'key': 'maximumJitAccessDuration', 'type': 'str'}, + } + + def __init__( + self, + *, + jit_access_enabled: bool, + jit_approval_mode: Optional[Union[str, "_models.JitApprovalMode"]] = None, + jit_approvers: Optional[List["_models.JitApproverDefinition"]] = None, + maximum_jit_access_duration: Optional[str] = None, + **kwargs + ): + """ + :keyword jit_access_enabled: Required. Whether the JIT access is enabled. + :paramtype jit_access_enabled: bool + :keyword jit_approval_mode: JIT approval mode. Known values are: "NotSpecified", "AutoApprove", + "ManualApprove". + :paramtype jit_approval_mode: str or + ~azure.mgmt.managedapplication.v2018_09_01_preview.models.JitApprovalMode + :keyword jit_approvers: The JIT approvers. + :paramtype jit_approvers: + list[~azure.mgmt.managedapplication.v2018_09_01_preview.models.JitApproverDefinition] + :keyword maximum_jit_access_duration: The maximum duration JIT access is granted. This is an + ISO8601 time period value. + :paramtype maximum_jit_access_duration: str + """ + super(ApplicationJitAccessPolicy, self).__init__(**kwargs) + self.jit_access_enabled = jit_access_enabled + self.jit_approval_mode = jit_approval_mode + self.jit_approvers = jit_approvers + self.maximum_jit_access_duration = maximum_jit_access_duration + + +class ApplicationListResult(msrest.serialization.Model): + """List of managed applications. + + :ivar value: The array of managed applications. + :vartype value: list[~azure.mgmt.managedapplication.v2018_09_01_preview.models.Application] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Application]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["_models.Application"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + """ + :keyword value: The array of managed applications. + :paramtype value: list[~azure.mgmt.managedapplication.v2018_09_01_preview.models.Application] + :keyword next_link: The URL to use for getting the next set of results. + :paramtype next_link: str + """ + super(ApplicationListResult, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class ApplicationPackageContact(msrest.serialization.Model): + """The application package contact information. + + All required parameters must be populated in order to send to Azure. + + :ivar contact_name: The contact name. + :vartype contact_name: str + :ivar email: Required. The contact email. + :vartype email: str + :ivar phone: Required. The contact phone number. + :vartype phone: str + """ + + _validation = { + 'email': {'required': True}, + 'phone': {'required': True}, + } + + _attribute_map = { + 'contact_name': {'key': 'contactName', 'type': 'str'}, + 'email': {'key': 'email', 'type': 'str'}, + 'phone': {'key': 'phone', 'type': 'str'}, + } + + def __init__( + self, + *, + email: str, + phone: str, + contact_name: Optional[str] = None, + **kwargs + ): + """ + :keyword contact_name: The contact name. + :paramtype contact_name: str + :keyword email: Required. The contact email. + :paramtype email: str + :keyword phone: Required. The contact phone number. + :paramtype phone: str + """ + super(ApplicationPackageContact, self).__init__(**kwargs) + self.contact_name = contact_name + self.email = email + self.phone = phone + + +class ApplicationPackageSupportUrls(msrest.serialization.Model): + """The appliance package support URLs. + + :ivar public_azure: The public azure support URL. + :vartype public_azure: str + :ivar government_cloud: The government cloud support URL. + :vartype government_cloud: str + """ + + _attribute_map = { + 'public_azure': {'key': 'publicAzure', 'type': 'str'}, + 'government_cloud': {'key': 'governmentCloud', 'type': 'str'}, + } + + def __init__( + self, + *, + public_azure: Optional[str] = None, + government_cloud: Optional[str] = None, + **kwargs + ): + """ + :keyword public_azure: The public azure support URL. + :paramtype public_azure: str + :keyword government_cloud: The government cloud support URL. + :paramtype government_cloud: str + """ + super(ApplicationPackageSupportUrls, self).__init__(**kwargs) + self.public_azure = public_azure + self.government_cloud = government_cloud + + +class ApplicationPatchable(GenericResource): + """Information about managed application. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Resource ID. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar location: Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar managed_by: ID of the resource that manages this resource. + :vartype managed_by: str + :ivar sku: The SKU of the resource. + :vartype sku: ~azure.mgmt.managedapplication.v2018_09_01_preview.models.Sku + :ivar plan: The plan information. + :vartype plan: ~azure.mgmt.managedapplication.v2018_09_01_preview.models.PlanPatchable + :ivar kind: The kind of the managed application. Allowed values are MarketPlace and + ServiceCatalog. + :vartype kind: str + :ivar identity: The identity of the resource. + :vartype identity: ~azure.mgmt.managedapplication.v2018_09_01_preview.models.Identity + :ivar managed_resource_group_id: The managed resource group Id. + :vartype managed_resource_group_id: str + :ivar application_definition_id: The fully qualified path of managed application definition Id. + :vartype application_definition_id: str + :ivar parameters: Name and value pairs that define the managed application parameters. It can + be a JObject or a well formed JSON string. + :vartype parameters: any + :ivar outputs: Name and value pairs that define the managed application outputs. + :vartype outputs: any + :ivar provisioning_state: The managed application provisioning state. Known values are: + "NotSpecified", "Accepted", "Running", "Ready", "Creating", "Created", "Deleting", "Deleted", + "Canceled", "Failed", "Succeeded", "Updating". + :vartype provisioning_state: str or + ~azure.mgmt.managedapplication.v2018_09_01_preview.models.ProvisioningState + :ivar billing_details: The managed application billing details. + :vartype billing_details: + ~azure.mgmt.managedapplication.v2018_09_01_preview.models.ApplicationBillingDetailsDefinition + :ivar jit_access_policy: The managed application Jit access policy. + :vartype jit_access_policy: + ~azure.mgmt.managedapplication.v2018_09_01_preview.models.ApplicationJitAccessPolicy + :ivar publisher_tenant_id: The publisher tenant Id. + :vartype publisher_tenant_id: str + :ivar authorizations: The read-only authorizations property that is retrieved from the + application package. + :vartype authorizations: + list[~azure.mgmt.managedapplication.v2018_09_01_preview.models.ApplicationAuthorization] + :ivar customer_support: The read-only customer support property that is retrieved from the + application package. + :vartype customer_support: + ~azure.mgmt.managedapplication.v2018_09_01_preview.models.ApplicationPackageContact + :ivar support_urls: The read-only support URLs property that is retrieved from the application + package. + :vartype support_urls: + ~azure.mgmt.managedapplication.v2018_09_01_preview.models.ApplicationPackageSupportUrls + :ivar artifacts: The collection of managed application artifacts. + :vartype artifacts: + list[~azure.mgmt.managedapplication.v2018_09_01_preview.models.ApplicationArtifact] + :ivar created_by: The client entity that created the JIT request. + :vartype created_by: + ~azure.mgmt.managedapplication.v2018_09_01_preview.models.ApplicationClientDetails + :ivar updated_by: The client entity that last updated the JIT request. + :vartype updated_by: + ~azure.mgmt.managedapplication.v2018_09_01_preview.models.ApplicationClientDetails + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'kind': {'pattern': r'^[-\w\._,\(\)]+$'}, + 'outputs': {'readonly': True}, + 'provisioning_state': {'readonly': True}, + 'billing_details': {'readonly': True}, + 'publisher_tenant_id': {'readonly': True}, + 'authorizations': {'readonly': True}, + 'customer_support': {'readonly': True}, + 'support_urls': {'readonly': True}, + 'artifacts': {'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'}, + 'location': {'key': 'location', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + 'managed_by': {'key': 'managedBy', 'type': 'str'}, + 'sku': {'key': 'sku', 'type': 'Sku'}, + 'plan': {'key': 'plan', 'type': 'PlanPatchable'}, + 'kind': {'key': 'kind', 'type': 'str'}, + 'identity': {'key': 'identity', 'type': 'Identity'}, + 'managed_resource_group_id': {'key': 'properties.managedResourceGroupId', 'type': 'str'}, + 'application_definition_id': {'key': 'properties.applicationDefinitionId', 'type': 'str'}, + 'parameters': {'key': 'properties.parameters', 'type': 'object'}, + 'outputs': {'key': 'properties.outputs', 'type': 'object'}, + 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + 'billing_details': {'key': 'properties.billingDetails', 'type': 'ApplicationBillingDetailsDefinition'}, + 'jit_access_policy': {'key': 'properties.jitAccessPolicy', 'type': 'ApplicationJitAccessPolicy'}, + 'publisher_tenant_id': {'key': 'properties.publisherTenantId', 'type': 'str'}, + 'authorizations': {'key': 'properties.authorizations', 'type': '[ApplicationAuthorization]'}, + 'customer_support': {'key': 'properties.customerSupport', 'type': 'ApplicationPackageContact'}, + 'support_urls': {'key': 'properties.supportUrls', 'type': 'ApplicationPackageSupportUrls'}, + 'artifacts': {'key': 'properties.artifacts', 'type': '[ApplicationArtifact]'}, + 'created_by': {'key': 'properties.createdBy', 'type': 'ApplicationClientDetails'}, + 'updated_by': {'key': 'properties.updatedBy', 'type': 'ApplicationClientDetails'}, + } + + def __init__( + self, + *, + location: Optional[str] = None, + tags: Optional[Dict[str, str]] = None, + managed_by: Optional[str] = None, + sku: Optional["_models.Sku"] = None, + plan: Optional["_models.PlanPatchable"] = None, + kind: Optional[str] = None, + identity: Optional["_models.Identity"] = None, + managed_resource_group_id: Optional[str] = None, + application_definition_id: Optional[str] = None, + parameters: Optional[Any] = None, + jit_access_policy: Optional["_models.ApplicationJitAccessPolicy"] = None, + **kwargs + ): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword managed_by: ID of the resource that manages this resource. + :paramtype managed_by: str + :keyword sku: The SKU of the resource. + :paramtype sku: ~azure.mgmt.managedapplication.v2018_09_01_preview.models.Sku + :keyword plan: The plan information. + :paramtype plan: ~azure.mgmt.managedapplication.v2018_09_01_preview.models.PlanPatchable + :keyword kind: The kind of the managed application. Allowed values are MarketPlace and + ServiceCatalog. + :paramtype kind: str + :keyword identity: The identity of the resource. + :paramtype identity: ~azure.mgmt.managedapplication.v2018_09_01_preview.models.Identity + :keyword managed_resource_group_id: The managed resource group Id. + :paramtype managed_resource_group_id: str + :keyword application_definition_id: The fully qualified path of managed application definition + Id. + :paramtype application_definition_id: str + :keyword parameters: Name and value pairs that define the managed application parameters. It + can be a JObject or a well formed JSON string. + :paramtype parameters: any + :keyword jit_access_policy: The managed application Jit access policy. + :paramtype jit_access_policy: + ~azure.mgmt.managedapplication.v2018_09_01_preview.models.ApplicationJitAccessPolicy + """ + super(ApplicationPatchable, self).__init__(location=location, tags=tags, managed_by=managed_by, sku=sku, **kwargs) + self.plan = plan + self.kind = kind + self.identity = identity + self.managed_resource_group_id = managed_resource_group_id + self.application_definition_id = application_definition_id + self.parameters = parameters + self.outputs = None + self.provisioning_state = None + self.billing_details = None + self.jit_access_policy = jit_access_policy + self.publisher_tenant_id = None + self.authorizations = None + self.customer_support = None + self.support_urls = None + self.artifacts = None + self.created_by = None + self.updated_by = None + + +class ApplicationPolicy(msrest.serialization.Model): + """Managed application policy. + + :ivar name: The policy name. + :vartype name: str + :ivar policy_definition_id: The policy definition Id. + :vartype policy_definition_id: str + :ivar parameters: The policy parameters. + :vartype parameters: str + """ + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'policy_definition_id': {'key': 'policyDefinitionId', 'type': 'str'}, + 'parameters': {'key': 'parameters', 'type': 'str'}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + policy_definition_id: Optional[str] = None, + parameters: Optional[str] = None, + **kwargs + ): + """ + :keyword name: The policy name. + :paramtype name: str + :keyword policy_definition_id: The policy definition Id. + :paramtype policy_definition_id: str + :keyword parameters: The policy parameters. + :paramtype parameters: str + """ + super(ApplicationPolicy, self).__init__(**kwargs) + self.name = name + self.policy_definition_id = policy_definition_id + self.parameters = parameters + + +class ApplicationPropertiesPatchable(msrest.serialization.Model): + """The managed application properties. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar managed_resource_group_id: The managed resource group Id. + :vartype managed_resource_group_id: str + :ivar application_definition_id: The fully qualified path of managed application definition Id. + :vartype application_definition_id: str + :ivar parameters: Name and value pairs that define the managed application parameters. It can + be a JObject or a well formed JSON string. + :vartype parameters: any + :ivar outputs: Name and value pairs that define the managed application outputs. + :vartype outputs: any + :ivar provisioning_state: The managed application provisioning state. Known values are: + "NotSpecified", "Accepted", "Running", "Ready", "Creating", "Created", "Deleting", "Deleted", + "Canceled", "Failed", "Succeeded", "Updating". + :vartype provisioning_state: str or + ~azure.mgmt.managedapplication.v2018_09_01_preview.models.ProvisioningState + """ + + _validation = { + 'outputs': {'readonly': True}, + 'provisioning_state': {'readonly': True}, + } + + _attribute_map = { + 'managed_resource_group_id': {'key': 'managedResourceGroupId', 'type': 'str'}, + 'application_definition_id': {'key': 'applicationDefinitionId', 'type': 'str'}, + 'parameters': {'key': 'parameters', 'type': 'object'}, + 'outputs': {'key': 'outputs', 'type': 'object'}, + 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, + } + + def __init__( + self, + *, + managed_resource_group_id: Optional[str] = None, + application_definition_id: Optional[str] = None, + parameters: Optional[Any] = None, + **kwargs + ): + """ + :keyword managed_resource_group_id: The managed resource group Id. + :paramtype managed_resource_group_id: str + :keyword application_definition_id: The fully qualified path of managed application definition + Id. + :paramtype application_definition_id: str + :keyword parameters: Name and value pairs that define the managed application parameters. It + can be a JObject or a well formed JSON string. + :paramtype parameters: any + """ + super(ApplicationPropertiesPatchable, self).__init__(**kwargs) + self.managed_resource_group_id = managed_resource_group_id + self.application_definition_id = application_definition_id + self.parameters = parameters + self.outputs = None + self.provisioning_state = None + + +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.managedapplication.v2018_09_01_preview.models.ErrorDetail] + :ivar additional_info: The error additional info. + :vartype additional_info: + list[~azure.mgmt.managedapplication.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.). + + :ivar error: The error object. + :vartype error: ~azure.mgmt.managedapplication.v2018_09_01_preview.models.ErrorDetail + """ + + _attribute_map = { + 'error': {'key': 'error', 'type': 'ErrorDetail'}, + } + + def __init__( + self, + *, + error: Optional["_models.ErrorDetail"] = None, + **kwargs + ): + """ + :keyword error: The error object. + :paramtype error: ~azure.mgmt.managedapplication.v2018_09_01_preview.models.ErrorDetail + """ + super(ErrorResponse, self).__init__(**kwargs) + self.error = error + + +class Identity(msrest.serialization.Model): + """Identity for the resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar principal_id: The principal ID of resource identity. + :vartype principal_id: str + :ivar tenant_id: The tenant ID of resource. + :vartype tenant_id: str + :ivar type: The identity type. Known values are: "SystemAssigned", "UserAssigned", + "SystemAssigned, UserAssigned", "None". + :vartype type: str or + ~azure.mgmt.managedapplication.v2018_09_01_preview.models.ResourceIdentityType + :ivar user_assigned_identities: The list of user identities associated with the resource. The + user identity dictionary key references will be resource ids in the form: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'. + :vartype user_assigned_identities: dict[str, + ~azure.mgmt.managedapplication.v2018_09_01_preview.models.UserAssignedResourceIdentity] + """ + + _validation = { + 'principal_id': {'readonly': True}, + 'tenant_id': {'readonly': True}, + } + + _attribute_map = { + 'principal_id': {'key': 'principalId', 'type': 'str'}, + 'tenant_id': {'key': 'tenantId', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'user_assigned_identities': {'key': 'userAssignedIdentities', 'type': '{UserAssignedResourceIdentity}'}, + } + + def __init__( + self, + *, + type: Optional[Union[str, "_models.ResourceIdentityType"]] = None, + user_assigned_identities: Optional[Dict[str, "_models.UserAssignedResourceIdentity"]] = None, + **kwargs + ): + """ + :keyword type: The identity type. Known values are: "SystemAssigned", "UserAssigned", + "SystemAssigned, UserAssigned", "None". + :paramtype type: str or + ~azure.mgmt.managedapplication.v2018_09_01_preview.models.ResourceIdentityType + :keyword user_assigned_identities: The list of user identities associated with the resource. + The user identity dictionary key references will be resource ids in the form: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'. + :paramtype user_assigned_identities: dict[str, + ~azure.mgmt.managedapplication.v2018_09_01_preview.models.UserAssignedResourceIdentity] + """ + super(Identity, self).__init__(**kwargs) + self.principal_id = None + self.tenant_id = None + self.type = type + self.user_assigned_identities = user_assigned_identities + + +class JitApproverDefinition(msrest.serialization.Model): + """JIT approver definition. + + All required parameters must be populated in order to send to Azure. + + :ivar id: Required. The approver service principal Id. + :vartype id: str + :ivar type: The approver type. Known values are: "user", "group". + :vartype type: str or ~azure.mgmt.managedapplication.v2018_09_01_preview.models.JitApproverType + :ivar display_name: The approver display name. + :vartype display_name: str + """ + + _validation = { + 'id': {'required': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'display_name': {'key': 'displayName', 'type': 'str'}, + } + + def __init__( + self, + *, + id: str, + type: Optional[Union[str, "_models.JitApproverType"]] = None, + display_name: Optional[str] = None, + **kwargs + ): + """ + :keyword id: Required. The approver service principal Id. + :paramtype id: str + :keyword type: The approver type. Known values are: "user", "group". + :paramtype type: str or + ~azure.mgmt.managedapplication.v2018_09_01_preview.models.JitApproverType + :keyword display_name: The approver display name. + :paramtype display_name: str + """ + super(JitApproverDefinition, self).__init__(**kwargs) + self.id = id + self.type = type + self.display_name = display_name + + +class JitAuthorizationPolicies(msrest.serialization.Model): + """The JIT authorization policies. + + All required parameters must be populated in order to send to Azure. + + :ivar principal_id: Required. The the principal id that will be granted JIT access. + :vartype principal_id: str + :ivar role_definition_id: Required. The role definition id that will be granted to the + Principal. + :vartype role_definition_id: str + """ + + _validation = { + 'principal_id': {'required': True}, + 'role_definition_id': {'required': True}, + } + + _attribute_map = { + 'principal_id': {'key': 'principalId', 'type': 'str'}, + 'role_definition_id': {'key': 'roleDefinitionId', 'type': 'str'}, + } + + def __init__( + self, + *, + principal_id: str, + role_definition_id: str, + **kwargs + ): + """ + :keyword principal_id: Required. The the principal id that will be granted JIT access. + :paramtype principal_id: str + :keyword role_definition_id: Required. The role definition id that will be granted to the + Principal. + :paramtype role_definition_id: str + """ + super(JitAuthorizationPolicies, self).__init__(**kwargs) + self.principal_id = principal_id + self.role_definition_id = role_definition_id + + +class JitRequestDefinition(Resource): + """Information about JIT request definition. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Resource ID. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar location: Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar application_resource_id: The parent application id. + :vartype application_resource_id: str + :ivar publisher_tenant_id: The publisher tenant id. + :vartype publisher_tenant_id: str + :ivar jit_authorization_policies: The JIT authorization policies. + :vartype jit_authorization_policies: + list[~azure.mgmt.managedapplication.v2018_09_01_preview.models.JitAuthorizationPolicies] + :ivar jit_scheduling_policy: The JIT request properties. + :vartype jit_scheduling_policy: + ~azure.mgmt.managedapplication.v2018_09_01_preview.models.JitSchedulingPolicy + :ivar provisioning_state: The JIT request provisioning state. Known values are: "NotSpecified", + "Accepted", "Running", "Ready", "Creating", "Created", "Deleting", "Deleted", "Canceled", + "Failed", "Succeeded", "Updating". + :vartype provisioning_state: str or + ~azure.mgmt.managedapplication.v2018_09_01_preview.models.ProvisioningState + :ivar jit_request_state: The JIT request state. Known values are: "NotSpecified", "Pending", + "Approved", "Denied", "Failed", "Canceled", "Expired", "Timeout". + :vartype jit_request_state: str or + ~azure.mgmt.managedapplication.v2018_09_01_preview.models.JitRequestState + :ivar created_by: The client entity that created the JIT request. + :vartype created_by: + ~azure.mgmt.managedapplication.v2018_09_01_preview.models.ApplicationClientDetails + :ivar updated_by: The client entity that last updated the JIT request. + :vartype updated_by: + ~azure.mgmt.managedapplication.v2018_09_01_preview.models.ApplicationClientDetails + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'publisher_tenant_id': {'readonly': True}, + 'provisioning_state': {'readonly': True}, + 'jit_request_state': {'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'}, + 'location': {'key': 'location', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + 'application_resource_id': {'key': 'properties.applicationResourceId', 'type': 'str'}, + 'publisher_tenant_id': {'key': 'properties.publisherTenantId', 'type': 'str'}, + 'jit_authorization_policies': {'key': 'properties.jitAuthorizationPolicies', 'type': '[JitAuthorizationPolicies]'}, + 'jit_scheduling_policy': {'key': 'properties.jitSchedulingPolicy', 'type': 'JitSchedulingPolicy'}, + 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + 'jit_request_state': {'key': 'properties.jitRequestState', 'type': 'str'}, + 'created_by': {'key': 'properties.createdBy', 'type': 'ApplicationClientDetails'}, + 'updated_by': {'key': 'properties.updatedBy', 'type': 'ApplicationClientDetails'}, + } + + def __init__( + self, + *, + location: Optional[str] = None, + tags: Optional[Dict[str, str]] = None, + application_resource_id: Optional[str] = None, + jit_authorization_policies: Optional[List["_models.JitAuthorizationPolicies"]] = None, + jit_scheduling_policy: Optional["_models.JitSchedulingPolicy"] = None, + **kwargs + ): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword application_resource_id: The parent application id. + :paramtype application_resource_id: str + :keyword jit_authorization_policies: The JIT authorization policies. + :paramtype jit_authorization_policies: + list[~azure.mgmt.managedapplication.v2018_09_01_preview.models.JitAuthorizationPolicies] + :keyword jit_scheduling_policy: The JIT request properties. + :paramtype jit_scheduling_policy: + ~azure.mgmt.managedapplication.v2018_09_01_preview.models.JitSchedulingPolicy + """ + super(JitRequestDefinition, self).__init__(location=location, tags=tags, **kwargs) + self.application_resource_id = application_resource_id + self.publisher_tenant_id = None + self.jit_authorization_policies = jit_authorization_policies + self.jit_scheduling_policy = jit_scheduling_policy + self.provisioning_state = None + self.jit_request_state = None + self.created_by = None + self.updated_by = None + + +class JitRequestDefinitionListResult(msrest.serialization.Model): + """List of JIT requests. + + :ivar value: The array of Jit request definition. + :vartype value: + list[~azure.mgmt.managedapplication.v2018_09_01_preview.models.JitRequestDefinition] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[JitRequestDefinition]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["_models.JitRequestDefinition"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + """ + :keyword value: The array of Jit request definition. + :paramtype value: + list[~azure.mgmt.managedapplication.v2018_09_01_preview.models.JitRequestDefinition] + :keyword next_link: The URL to use for getting the next set of results. + :paramtype next_link: str + """ + super(JitRequestDefinitionListResult, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class JitRequestMetadata(msrest.serialization.Model): + """The JIT request metadata. + + :ivar origin_request_id: The origin request id. + :vartype origin_request_id: str + :ivar requestor_id: The requestor id. + :vartype requestor_id: str + :ivar tenant_display_name: The publisher's tenant name. + :vartype tenant_display_name: str + :ivar subject_display_name: The subject display name. + :vartype subject_display_name: str + """ + + _attribute_map = { + 'origin_request_id': {'key': 'originRequestId', 'type': 'str'}, + 'requestor_id': {'key': 'requestorId', 'type': 'str'}, + 'tenant_display_name': {'key': 'tenantDisplayName', 'type': 'str'}, + 'subject_display_name': {'key': 'subjectDisplayName', 'type': 'str'}, + } + + def __init__( + self, + *, + origin_request_id: Optional[str] = None, + requestor_id: Optional[str] = None, + tenant_display_name: Optional[str] = None, + subject_display_name: Optional[str] = None, + **kwargs + ): + """ + :keyword origin_request_id: The origin request id. + :paramtype origin_request_id: str + :keyword requestor_id: The requestor id. + :paramtype requestor_id: str + :keyword tenant_display_name: The publisher's tenant name. + :paramtype tenant_display_name: str + :keyword subject_display_name: The subject display name. + :paramtype subject_display_name: str + """ + super(JitRequestMetadata, self).__init__(**kwargs) + self.origin_request_id = origin_request_id + self.requestor_id = requestor_id + self.tenant_display_name = tenant_display_name + self.subject_display_name = subject_display_name + + +class JitRequestPatchable(msrest.serialization.Model): + """Information about JIT request. + + :ivar tags: A set of tags. Jit request tags. + :vartype tags: dict[str, str] + """ + + _attribute_map = { + 'tags': {'key': 'tags', 'type': '{str}'}, + } + + def __init__( + self, + *, + tags: Optional[Dict[str, str]] = None, + **kwargs + ): + """ + :keyword tags: A set of tags. Jit request tags. + :paramtype tags: dict[str, str] + """ + super(JitRequestPatchable, self).__init__(**kwargs) + self.tags = tags + + +class JitSchedulingPolicy(msrest.serialization.Model): + """The JIT scheduling policies. + + All required parameters must be populated in order to send to Azure. + + :ivar type: Required. The type of JIT schedule. Known values are: "NotSpecified", "Once", + "Recurring". + :vartype type: str or + ~azure.mgmt.managedapplication.v2018_09_01_preview.models.JitSchedulingType + :ivar duration: Required. The required duration of the JIT request. + :vartype duration: ~datetime.timedelta + :ivar start_time: Required. The start time of the request. + :vartype start_time: ~datetime.datetime + """ + + _validation = { + 'type': {'required': True}, + 'duration': {'required': True}, + 'start_time': {'required': True}, + } + + _attribute_map = { + 'type': {'key': 'type', 'type': 'str'}, + 'duration': {'key': 'duration', 'type': 'duration'}, + 'start_time': {'key': 'startTime', 'type': 'iso-8601'}, + } + + def __init__( + self, + *, + type: Union[str, "_models.JitSchedulingType"], + duration: datetime.timedelta, + start_time: datetime.datetime, + **kwargs + ): + """ + :keyword type: Required. The type of JIT schedule. Known values are: "NotSpecified", "Once", + "Recurring". + :paramtype type: str or + ~azure.mgmt.managedapplication.v2018_09_01_preview.models.JitSchedulingType + :keyword duration: Required. The required duration of the JIT request. + :paramtype duration: ~datetime.timedelta + :keyword start_time: Required. The start time of the request. + :paramtype start_time: ~datetime.datetime + """ + super(JitSchedulingPolicy, self).__init__(**kwargs) + self.type = type + self.duration = duration + self.start_time = start_time + + +class ListTokenRequest(msrest.serialization.Model): + """List token request body. + + :ivar authorization_audience: The authorization audience. + :vartype authorization_audience: str + :ivar user_assigned_identities: The user assigned identities. + :vartype user_assigned_identities: list[str] + """ + + _attribute_map = { + 'authorization_audience': {'key': 'authorizationAudience', 'type': 'str'}, + 'user_assigned_identities': {'key': 'userAssignedIdentities', 'type': '[str]'}, + } + + def __init__( + self, + *, + authorization_audience: Optional[str] = None, + user_assigned_identities: Optional[List[str]] = None, + **kwargs + ): + """ + :keyword authorization_audience: The authorization audience. + :paramtype authorization_audience: str + :keyword user_assigned_identities: The user assigned identities. + :paramtype user_assigned_identities: list[str] + """ + super(ListTokenRequest, self).__init__(**kwargs) + self.authorization_audience = authorization_audience + self.user_assigned_identities = user_assigned_identities + + +class ManagedIdentityToken(msrest.serialization.Model): + """The managed identity token for the managed app resource. + + :ivar access_token: The requested access token. + :vartype access_token: str + :ivar expires_in: The number of seconds the access token will be valid. + :vartype expires_in: str + :ivar expires_on: The timespan when the access token expires. This is represented as the number + of seconds from epoch. + :vartype expires_on: str + :ivar not_before: The timespan when the access token takes effect. This is represented as the + number of seconds from epoch. + :vartype not_before: str + :ivar authorization_audience: The aud (audience) the access token was request for. This is the + same as what was provided in the listTokens request. + :vartype authorization_audience: str + :ivar resource_id: The Azure resource ID for the issued token. This is either the managed + application ID or the user-assigned identity ID. + :vartype resource_id: str + :ivar token_type: The type of the token. + :vartype token_type: str + """ + + _attribute_map = { + 'access_token': {'key': 'accessToken', 'type': 'str'}, + 'expires_in': {'key': 'expiresIn', 'type': 'str'}, + 'expires_on': {'key': 'expiresOn', 'type': 'str'}, + 'not_before': {'key': 'notBefore', 'type': 'str'}, + 'authorization_audience': {'key': 'authorizationAudience', 'type': 'str'}, + 'resource_id': {'key': 'resourceId', 'type': 'str'}, + 'token_type': {'key': 'tokenType', 'type': 'str'}, + } + + def __init__( + self, + *, + access_token: Optional[str] = None, + expires_in: Optional[str] = None, + expires_on: Optional[str] = None, + not_before: Optional[str] = None, + authorization_audience: Optional[str] = None, + resource_id: Optional[str] = None, + token_type: Optional[str] = None, + **kwargs + ): + """ + :keyword access_token: The requested access token. + :paramtype access_token: str + :keyword expires_in: The number of seconds the access token will be valid. + :paramtype expires_in: str + :keyword expires_on: The timespan when the access token expires. This is represented as the + number of seconds from epoch. + :paramtype expires_on: str + :keyword not_before: The timespan when the access token takes effect. This is represented as + the number of seconds from epoch. + :paramtype not_before: str + :keyword authorization_audience: The aud (audience) the access token was request for. This is + the same as what was provided in the listTokens request. + :paramtype authorization_audience: str + :keyword resource_id: The Azure resource ID for the issued token. This is either the managed + application ID or the user-assigned identity ID. + :paramtype resource_id: str + :keyword token_type: The type of the token. + :paramtype token_type: str + """ + super(ManagedIdentityToken, self).__init__(**kwargs) + self.access_token = access_token + self.expires_in = expires_in + self.expires_on = expires_on + self.not_before = not_before + self.authorization_audience = authorization_audience + self.resource_id = resource_id + self.token_type = token_type + + +class ManagedIdentityTokenResult(msrest.serialization.Model): + """The array of managed identity tokens. + + :ivar value: The array of managed identity tokens. + :vartype value: + list[~azure.mgmt.managedapplication.v2018_09_01_preview.models.ManagedIdentityToken] + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[ManagedIdentityToken]'}, + } + + def __init__( + self, + *, + value: Optional[List["_models.ManagedIdentityToken"]] = None, + **kwargs + ): + """ + :keyword value: The array of managed identity tokens. + :paramtype value: + list[~azure.mgmt.managedapplication.v2018_09_01_preview.models.ManagedIdentityToken] + """ + super(ManagedIdentityTokenResult, self).__init__(**kwargs) + self.value = value + + +class Operation(msrest.serialization.Model): + """Details of a REST API operation, returned from the Resource Provider Operations API. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name: The name of the operation, as per Resource-Based Access Control (RBAC). Examples: + "Microsoft.Compute/virtualMachines/write", "Microsoft.Compute/virtualMachines/capture/action". + :vartype name: str + :ivar is_data_action: Whether the operation applies to data-plane. This is "true" for + data-plane operations and "false" for ARM/control-plane operations. + :vartype is_data_action: bool + :ivar display: Localized display information for this particular operation. + :vartype display: ~azure.mgmt.managedapplication.v2018_09_01_preview.models.OperationDisplay + :ivar origin: The intended executor of the operation; as in Resource Based Access Control + (RBAC) and audit logs UX. Default value is "user,system". Known values are: "user", "system", + "user,system". + :vartype origin: str or ~azure.mgmt.managedapplication.v2018_09_01_preview.models.Origin + :ivar action_type: Enum. Indicates the action type. "Internal" refers to actions that are for + internal only APIs. Known values are: "Internal". + :vartype action_type: str or + ~azure.mgmt.managedapplication.v2018_09_01_preview.models.ActionType + """ + + _validation = { + 'name': {'readonly': True}, + 'is_data_action': {'readonly': True}, + 'origin': {'readonly': True}, + 'action_type': {'readonly': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'is_data_action': {'key': 'isDataAction', 'type': 'bool'}, + 'display': {'key': 'display', 'type': 'OperationDisplay'}, + 'origin': {'key': 'origin', 'type': 'str'}, + 'action_type': {'key': 'actionType', 'type': 'str'}, + } + + def __init__( + self, + *, + display: Optional["_models.OperationDisplay"] = None, + **kwargs + ): + """ + :keyword display: Localized display information for this particular operation. + :paramtype display: ~azure.mgmt.managedapplication.v2018_09_01_preview.models.OperationDisplay + """ + super(Operation, self).__init__(**kwargs) + self.name = None + self.is_data_action = None + self.display = display + self.origin = None + self.action_type = None + + +class OperationAutoGenerated(msrest.serialization.Model): + """Microsoft.Solutions operation. + + :ivar name: Operation name: {provider}/{resource}/{operation}. + :vartype name: str + :ivar display: The object that represents the operation. + :vartype display: + ~azure.mgmt.managedapplication.v2018_09_01_preview.models.OperationDisplayAutoGenerated + """ + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'display': {'key': 'display', 'type': 'OperationDisplayAutoGenerated'}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + display: Optional["_models.OperationDisplayAutoGenerated"] = None, + **kwargs + ): + """ + :keyword name: Operation name: {provider}/{resource}/{operation}. + :paramtype name: str + :keyword display: The object that represents the operation. + :paramtype display: + ~azure.mgmt.managedapplication.v2018_09_01_preview.models.OperationDisplayAutoGenerated + """ + super(OperationAutoGenerated, self).__init__(**kwargs) + self.name = name + self.display = display + + +class OperationDisplay(msrest.serialization.Model): + """Localized display information for this particular operation. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar provider: The localized friendly form of the resource provider name, e.g. "Microsoft + Monitoring Insights" or "Microsoft Compute". + :vartype provider: str + :ivar resource: The localized friendly name of the resource type related to this operation. + E.g. "Virtual Machines" or "Job Schedule Collections". + :vartype resource: str + :ivar operation: The concise, localized friendly name for the operation; suitable for + dropdowns. E.g. "Create or Update Virtual Machine", "Restart Virtual Machine". + :vartype operation: str + :ivar description: The short, localized friendly description of the operation; suitable for + tool tips and detailed views. + :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 OperationDisplayAutoGenerated(msrest.serialization.Model): + """The object that represents the operation. + + :ivar provider: Service provider: Microsoft.Solutions. + :vartype provider: str + :ivar resource: Resource on which the operation is performed: Application, JitRequest, etc. + :vartype resource: str + :ivar operation: Operation type: Read, write, delete, etc. + :vartype operation: str + """ + + _attribute_map = { + 'provider': {'key': 'provider', 'type': 'str'}, + 'resource': {'key': 'resource', 'type': 'str'}, + 'operation': {'key': 'operation', 'type': 'str'}, + } + + def __init__( + self, + *, + provider: Optional[str] = None, + resource: Optional[str] = None, + operation: Optional[str] = None, + **kwargs + ): + """ + :keyword provider: Service provider: Microsoft.Solutions. + :paramtype provider: str + :keyword resource: Resource on which the operation is performed: Application, JitRequest, etc. + :paramtype resource: str + :keyword operation: Operation type: Read, write, delete, etc. + :paramtype operation: str + """ + super(OperationDisplayAutoGenerated, self).__init__(**kwargs) + self.provider = provider + self.resource = resource + self.operation = operation + + +class OperationListResult(msrest.serialization.Model): + """A list of REST API operations supported by an Azure Resource Provider. It contains an URL link to get the next set of results. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: List of operations supported by the resource provider. + :vartype value: list[~azure.mgmt.managedapplication.v2018_09_01_preview.models.Operation] + :ivar next_link: URL to get the next set of operation list results (if there are any). + :vartype next_link: str + """ + + _validation = { + 'value': {'readonly': True}, + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Operation]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(OperationListResult, self).__init__(**kwargs) + self.value = None + self.next_link = None + + +class Plan(msrest.serialization.Model): + """Plan for the managed application. + + All required parameters must be populated in order to send to Azure. + + :ivar name: Required. The plan name. + :vartype name: str + :ivar publisher: Required. The publisher ID. + :vartype publisher: str + :ivar product: Required. The product code. + :vartype product: str + :ivar promotion_code: The promotion code. + :vartype promotion_code: str + :ivar version: Required. The plan's version. + :vartype version: str + """ + + _validation = { + 'name': {'required': True}, + 'publisher': {'required': True}, + 'product': {'required': True}, + 'version': {'required': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'publisher': {'key': 'publisher', 'type': 'str'}, + 'product': {'key': 'product', 'type': 'str'}, + 'promotion_code': {'key': 'promotionCode', 'type': 'str'}, + 'version': {'key': 'version', 'type': 'str'}, + } + + def __init__( + self, + *, + name: str, + publisher: str, + product: str, + version: str, + promotion_code: Optional[str] = None, + **kwargs + ): + """ + :keyword name: Required. The plan name. + :paramtype name: str + :keyword publisher: Required. The publisher ID. + :paramtype publisher: str + :keyword product: Required. The product code. + :paramtype product: str + :keyword promotion_code: The promotion code. + :paramtype promotion_code: str + :keyword version: Required. The plan's version. + :paramtype version: str + """ + super(Plan, self).__init__(**kwargs) + self.name = name + self.publisher = publisher + self.product = product + self.promotion_code = promotion_code + self.version = version + + +class PlanPatchable(msrest.serialization.Model): + """Plan for the managed application. + + :ivar name: The plan name. + :vartype name: str + :ivar publisher: The publisher ID. + :vartype publisher: str + :ivar product: The product code. + :vartype product: str + :ivar promotion_code: The promotion code. + :vartype promotion_code: str + :ivar version: The plan's version. + :vartype version: str + """ + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'publisher': {'key': 'publisher', 'type': 'str'}, + 'product': {'key': 'product', 'type': 'str'}, + 'promotion_code': {'key': 'promotionCode', 'type': 'str'}, + 'version': {'key': 'version', 'type': 'str'}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + publisher: Optional[str] = None, + product: Optional[str] = None, + promotion_code: Optional[str] = None, + version: Optional[str] = None, + **kwargs + ): + """ + :keyword name: The plan name. + :paramtype name: str + :keyword publisher: The publisher ID. + :paramtype publisher: str + :keyword product: The product code. + :paramtype product: str + :keyword promotion_code: The promotion code. + :paramtype promotion_code: str + :keyword version: The plan's version. + :paramtype version: str + """ + super(PlanPatchable, self).__init__(**kwargs) + self.name = name + self.publisher = publisher + self.product = product + self.promotion_code = promotion_code + self.version = version + + +class Sku(msrest.serialization.Model): + """SKU for the resource. + + All required parameters must be populated in order to send to Azure. + + :ivar name: Required. The SKU name. + :vartype name: str + :ivar tier: The SKU tier. + :vartype tier: str + :ivar size: The SKU size. + :vartype size: str + :ivar family: The SKU family. + :vartype family: str + :ivar model: The SKU model. + :vartype model: str + :ivar capacity: The SKU capacity. + :vartype capacity: int + """ + + _validation = { + 'name': {'required': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'tier': {'key': 'tier', 'type': 'str'}, + 'size': {'key': 'size', 'type': 'str'}, + 'family': {'key': 'family', 'type': 'str'}, + 'model': {'key': 'model', 'type': 'str'}, + 'capacity': {'key': 'capacity', 'type': 'int'}, + } + + def __init__( + self, + *, + name: str, + tier: Optional[str] = None, + size: Optional[str] = None, + family: Optional[str] = None, + model: Optional[str] = None, + capacity: Optional[int] = None, + **kwargs + ): + """ + :keyword name: Required. The SKU name. + :paramtype name: str + :keyword tier: The SKU tier. + :paramtype tier: str + :keyword size: The SKU size. + :paramtype size: str + :keyword family: The SKU family. + :paramtype family: str + :keyword model: The SKU model. + :paramtype model: str + :keyword capacity: The SKU capacity. + :paramtype capacity: int + """ + super(Sku, self).__init__(**kwargs) + self.name = name + self.tier = tier + self.size = size + self.family = family + self.model = model + self.capacity = capacity + + +class UpdateAccessDefinition(msrest.serialization.Model): + """Update access request definition. + + All required parameters must be populated in order to send to Azure. + + :ivar approver: The approver name. + :vartype approver: str + :ivar metadata: Required. The JIT request metadata. + :vartype metadata: ~azure.mgmt.managedapplication.v2018_09_01_preview.models.JitRequestMetadata + :ivar status: Required. The JIT status. Known values are: "NotSpecified", "Elevate", "Remove". + :vartype status: str or ~azure.mgmt.managedapplication.v2018_09_01_preview.models.Status + :ivar sub_status: Required. The JIT status. Known values are: "NotSpecified", "Approved", + "Denied", "Failed", "Expired", "Timeout". + :vartype sub_status: str or ~azure.mgmt.managedapplication.v2018_09_01_preview.models.Substatus + """ + + _validation = { + 'metadata': {'required': True}, + 'status': {'required': True}, + 'sub_status': {'required': True}, + } + + _attribute_map = { + 'approver': {'key': 'approver', 'type': 'str'}, + 'metadata': {'key': 'metadata', 'type': 'JitRequestMetadata'}, + 'status': {'key': 'status', 'type': 'str'}, + 'sub_status': {'key': 'subStatus', 'type': 'str'}, + } + + def __init__( + self, + *, + metadata: "_models.JitRequestMetadata", + status: Union[str, "_models.Status"], + sub_status: Union[str, "_models.Substatus"], + approver: Optional[str] = None, + **kwargs + ): + """ + :keyword approver: The approver name. + :paramtype approver: str + :keyword metadata: Required. The JIT request metadata. + :paramtype metadata: + ~azure.mgmt.managedapplication.v2018_09_01_preview.models.JitRequestMetadata + :keyword status: Required. The JIT status. Known values are: "NotSpecified", "Elevate", + "Remove". + :paramtype status: str or ~azure.mgmt.managedapplication.v2018_09_01_preview.models.Status + :keyword sub_status: Required. The JIT status. Known values are: "NotSpecified", "Approved", + "Denied", "Failed", "Expired", "Timeout". + :paramtype sub_status: str or + ~azure.mgmt.managedapplication.v2018_09_01_preview.models.Substatus + """ + super(UpdateAccessDefinition, self).__init__(**kwargs) + self.approver = approver + self.metadata = metadata + self.status = status + self.sub_status = sub_status + + +class UserAssignedResourceIdentity(msrest.serialization.Model): + """Represents the user assigned identity that is contained within the UserAssignedIdentities dictionary on ResourceIdentity. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar principal_id: The principal id of user assigned identity. + :vartype principal_id: str + :ivar tenant_id: The tenant id of user assigned identity. + :vartype tenant_id: str + """ + + _validation = { + 'principal_id': {'readonly': True}, + 'tenant_id': {'readonly': True}, + } + + _attribute_map = { + 'principal_id': {'key': 'principalId', 'type': 'str'}, + 'tenant_id': {'key': 'tenantId', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(UserAssignedResourceIdentity, self).__init__(**kwargs) + self.principal_id = None + self.tenant_id = None diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_09_01_preview/models/_patch.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_09_01_preview/models/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_09_01_preview/models/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_09_01_preview/operations/__init__.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_09_01_preview/operations/__init__.py new file mode 100644 index 000000000000..b93ecbbe65e2 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_09_01_preview/operations/__init__.py @@ -0,0 +1,24 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._application_client_operations import ApplicationClientOperationsMixin +from ._applications_operations import ApplicationsOperations +from ._application_definitions_operations import ApplicationDefinitionsOperations +from ._jit_requests_operations import JitRequestsOperations + +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk +__all__ = [ + 'ApplicationClientOperationsMixin', + 'ApplicationsOperations', + 'ApplicationDefinitionsOperations', + 'JitRequestsOperations', +] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_09_01_preview/operations/_application_client_operations.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_09_01_preview/operations/_application_client_operations.py new file mode 100644 index 000000000000..edec24674494 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_09_01_preview/operations/_application_client_operations.py @@ -0,0 +1,134 @@ +# 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.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._vendor import MixinABC, _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_operations_request( + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.Solutions/operations") + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + +class ApplicationClientOperationsMixin(MixinABC): + + @distributed_trace + def list_operations( + self, + **kwargs: Any + ) -> Iterable[_models.OperationListResult]: + """Lists all of the available Microsoft.Solutions REST API operations. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either OperationListResult or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.managedapplication.v2018_09_01_preview.models.OperationListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-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', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_operations_request( + api_version=api_version, + template_url=self.list_operations.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_operations_request( + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list_operations.metadata = {'url': "/providers/Microsoft.Solutions/operations"} # type: ignore diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_09_01_preview/operations/_application_definitions_operations.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_09_01_preview/operations/_application_definitions_operations.py new file mode 100644 index 000000000000..d26288665926 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_09_01_preview/operations/_application_definitions_operations.py @@ -0,0 +1,1160 @@ +# 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.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._vendor import MixinABC, _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_request( + resource_group_name: str, + application_definition_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "applicationDefinitionName": _SERIALIZER.url("application_definition_name", application_definition_name, 'str', max_length=64, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_delete_request( + resource_group_name: str, + application_definition_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "applicationDefinitionName": _SERIALIZER.url("application_definition_name", application_definition_name, 'str', max_length=64, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_create_or_update_request( + resource_group_name: str, + application_definition_name: str, + subscription_id: str, + *, + json: Optional[_models.ApplicationDefinition] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "applicationDefinitionName": _SERIALIZER.url("application_definition_name", application_definition_name, 'str', max_length=64, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_update_request( + subscription_id: str, + resource_group_name: str, + application_definition_name: str, + *, + json: Optional[_models.ApplicationDefinitionPatchable] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "applicationDefinitionName": _SERIALIZER.url("application_definition_name", application_definition_name, 'str', max_length=64, min_length=3), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_list_by_resource_group_request( + resource_group_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_list_by_subscription_request( + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Solutions/applicationDefinitions") + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_get_by_id_request( + resource_group_name: str, + application_definition_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "applicationDefinitionName": _SERIALIZER.url("application_definition_name", application_definition_name, 'str', max_length=64, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_delete_by_id_request( + resource_group_name: str, + application_definition_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "applicationDefinitionName": _SERIALIZER.url("application_definition_name", application_definition_name, 'str', max_length=64, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_create_or_update_by_id_request( + resource_group_name: str, + application_definition_name: str, + subscription_id: str, + *, + json: Optional[_models.ApplicationDefinition] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "applicationDefinitionName": _SERIALIZER.url("application_definition_name", application_definition_name, 'str', max_length=64, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_update_by_id_request( + subscription_id: str, + resource_group_name: str, + application_definition_name: str, + *, + json: Optional[_models.ApplicationDefinitionPatchable] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "applicationDefinitionName": _SERIALIZER.url("application_definition_name", application_definition_name, 'str', max_length=64, min_length=3), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + +class ApplicationDefinitionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.managedapplication.v2018_09_01_preview.ApplicationClient`'s + :attr:`application_definitions` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + + @distributed_trace + def get( + self, + resource_group_name: str, + application_definition_name: str, + **kwargs: Any + ) -> Optional[_models.ApplicationDefinition]: + """Gets the managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. + :type application_definition_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ApplicationDefinition, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2018_09_01_preview.models.ApplicationDefinition or None + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.ApplicationDefinition]] + + + request = build_get_request( + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('ApplicationDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore + + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + application_definition_name: str, + **kwargs: Any + ) -> None: + """Deletes the managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition to delete. + :type application_definition_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_request( + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore + + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + application_definition_name: str, + parameters: _models.ApplicationDefinition, + **kwargs: Any + ) -> _models.ApplicationDefinition: + """Creates or updates a managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. + :type application_definition_name: str + :param parameters: Parameters supplied to the create or update an managed application + definition. + :type parameters: + ~azure.mgmt.managedapplication.v2018_09_01_preview.models.ApplicationDefinition + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ApplicationDefinition, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2018_09_01_preview.models.ApplicationDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationDefinition] + + _json = self._serialize.body(parameters, 'ApplicationDefinition') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # 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, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('ApplicationDefinition', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('ApplicationDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore + + + @distributed_trace + def update( + self, + resource_group_name: str, + application_definition_name: str, + parameters: _models.ApplicationDefinitionPatchable, + **kwargs: Any + ) -> _models.ApplicationDefinition: + """Updates the managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. + :type application_definition_name: str + :param parameters: Parameters supplied to the update a managed application definition. + :type parameters: + ~azure.mgmt.managedapplication.v2018_09_01_preview.models.ApplicationDefinitionPatchable + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ApplicationDefinition, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2018_09_01_preview.models.ApplicationDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationDefinition] + + _json = self._serialize.body(parameters, 'ApplicationDefinitionPatchable') + + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ApplicationDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore + + + @distributed_trace + def list_by_resource_group( + self, + resource_group_name: str, + **kwargs: Any + ) -> Iterable[_models.ApplicationDefinitionListResult]: + """Lists the managed application definitions in a resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ApplicationDefinitionListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.managedapplication.v2018_09_01_preview.models.ApplicationDefinitionListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationDefinitionListResult] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_resource_group.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ApplicationDefinitionListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions"} # type: ignore + + @distributed_trace + def list_by_subscription( + self, + **kwargs: Any + ) -> Iterable[_models.ApplicationDefinitionListResult]: + """Lists the managed application definitions in a subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ApplicationDefinitionListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.managedapplication.v2018_09_01_preview.models.ApplicationDefinitionListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationDefinitionListResult] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ApplicationDefinitionListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Solutions/applicationDefinitions"} # type: ignore + + @distributed_trace + def get_by_id( + self, + resource_group_name: str, + application_definition_name: str, + **kwargs: Any + ) -> Optional[_models.ApplicationDefinition]: + """Gets the managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. + :type application_definition_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ApplicationDefinition, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2018_09_01_preview.models.ApplicationDefinition or None + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.ApplicationDefinition]] + + + request = build_get_by_id_request( + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_by_id.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('ApplicationDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_by_id.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore + + + @distributed_trace + def delete_by_id( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + application_definition_name: str, + **kwargs: Any + ) -> None: + """Deletes the managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. + :type application_definition_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_by_id_request( + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete_by_id.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete_by_id.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore + + + @distributed_trace + def create_or_update_by_id( + self, + resource_group_name: str, + application_definition_name: str, + parameters: _models.ApplicationDefinition, + **kwargs: Any + ) -> _models.ApplicationDefinition: + """Creates or updates a managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. + :type application_definition_name: str + :param parameters: Parameters supplied to the create or update a managed application + definition. + :type parameters: + ~azure.mgmt.managedapplication.v2018_09_01_preview.models.ApplicationDefinition + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ApplicationDefinition, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2018_09_01_preview.models.ApplicationDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationDefinition] + + _json = self._serialize.body(parameters, 'ApplicationDefinition') + + request = build_create_or_update_by_id_request( + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + 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'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # 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, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('ApplicationDefinition', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('ApplicationDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_or_update_by_id.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore + + + @distributed_trace + def update_by_id( + self, + resource_group_name: str, + application_definition_name: str, + parameters: _models.ApplicationDefinitionPatchable, + **kwargs: Any + ) -> _models.ApplicationDefinition: + """Updates the managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. + :type application_definition_name: str + :param parameters: Parameters supplied to the update a managed application definition. + :type parameters: + ~azure.mgmt.managedapplication.v2018_09_01_preview.models.ApplicationDefinitionPatchable + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ApplicationDefinition, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2018_09_01_preview.models.ApplicationDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationDefinition] + + _json = self._serialize.body(parameters, 'ApplicationDefinitionPatchable') + + request = build_update_by_id_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.update_by_id.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ApplicationDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + update_by_id.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore + diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_09_01_preview/operations/_applications_operations.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_09_01_preview/operations/_applications_operations.py new file mode 100644 index 000000000000..61dda0e0397a --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_09_01_preview/operations/_applications_operations.py @@ -0,0 +1,1992 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast + +from msrest import Serializer + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from .._vendor import MixinABC, _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_request( + resource_group_name: str, + application_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "applicationName": _SERIALIZER.url("application_name", application_name, 'str', max_length=64, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_delete_request_initial( + resource_group_name: str, + application_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "applicationName": _SERIALIZER.url("application_name", application_name, 'str', max_length=64, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_create_or_update_request_initial( + resource_group_name: str, + application_name: str, + subscription_id: str, + *, + json: Optional[_models.Application] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "applicationName": _SERIALIZER.url("application_name", application_name, 'str', max_length=64, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_update_request_initial( + resource_group_name: str, + application_name: str, + subscription_id: str, + *, + json: Optional[_models.ApplicationPatchable] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "applicationName": _SERIALIZER.url("application_name", application_name, 'str', max_length=64, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_list_by_resource_group_request( + resource_group_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_list_by_subscription_request( + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Solutions/applications") + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_get_by_id_request( + application_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/{applicationId}") + path_format_arguments = { + "applicationId": _SERIALIZER.url("application_id", application_id, 'str', skip_quote=True), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_delete_by_id_request_initial( + application_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/{applicationId}") + path_format_arguments = { + "applicationId": _SERIALIZER.url("application_id", application_id, 'str', skip_quote=True), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_create_or_update_by_id_request_initial( + application_id: str, + *, + json: Optional[_models.Application] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/{applicationId}") + path_format_arguments = { + "applicationId": _SERIALIZER.url("application_id", application_id, 'str', skip_quote=True), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_update_by_id_request_initial( + application_id: str, + *, + json: Optional[_models.ApplicationPatchable] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/{applicationId}") + path_format_arguments = { + "applicationId": _SERIALIZER.url("application_id", application_id, 'str', skip_quote=True), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_refresh_permissions_request_initial( + resource_group_name: str, + application_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}/refreshPermissions") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "applicationName": _SERIALIZER.url("application_name", application_name, 'str', max_length=64, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_update_access_request_initial( + subscription_id: str, + resource_group_name: str, + application_name: str, + *, + json: Optional[_models.UpdateAccessDefinition] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}/updateAccess") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "applicationName": _SERIALIZER.url("application_name", application_name, 'str', max_length=64, min_length=3), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_list_tokens_request( + subscription_id: str, + resource_group_name: str, + application_name: str, + *, + json: Optional[_models.ListTokenRequest] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}/listTokens") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "applicationName": _SERIALIZER.url("application_name", application_name, 'str', max_length=64, min_length=3), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + +class ApplicationsOperations: # pylint: disable=too-many-public-methods + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.managedapplication.v2018_09_01_preview.ApplicationClient`'s + :attr:`applications` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + + @distributed_trace + def get( + self, + resource_group_name: str, + application_name: str, + **kwargs: Any + ) -> Optional[_models.Application]: + """Gets the managed application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_name: The name of the managed application. + :type application_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Application, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2018_09_01_preview.models.Application or None + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.Application]] + + + request = build_get_request( + resource_group_name=resource_group_name, + application_name=application_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('Application', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}"} # type: ignore + + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + application_name: str, + **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + application_name=application_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}"} # type: ignore + + + @distributed_trace + def begin_delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + application_name: str, + **kwargs: Any + ) -> LROPoller[None]: + """Deletes the managed application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_name: The name of the managed application. + :type application_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._delete_initial( # type: ignore + resource_group_name=resource_group_name, + application_name=application_name, + api_version=api_version, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}"} # type: ignore + + def _create_or_update_initial( + self, + resource_group_name: str, + application_name: str, + parameters: _models.Application, + **kwargs: Any + ) -> _models.Application: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Application] + + _json = self._serialize.body(parameters, 'Application') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + application_name=application_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('Application', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('Application', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}"} # type: ignore + + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + application_name: str, + parameters: _models.Application, + **kwargs: Any + ) -> LROPoller[_models.Application]: + """Creates or updates a managed application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_name: The name of the managed application. + :type application_name: str + :param parameters: Parameters supplied to the create or update a managed application. + :type parameters: ~azure.mgmt.managedapplication.v2018_09_01_preview.models.Application + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Application or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.managedapplication.v2018_09_01_preview.models.Application] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Application] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._create_or_update_initial( # type: ignore + resource_group_name=resource_group_name, + application_name=application_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('Application', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}"} # type: ignore + + def _update_initial( + self, + resource_group_name: str, + application_name: str, + parameters: Optional[_models.ApplicationPatchable] = None, + **kwargs: Any + ) -> _models.ApplicationPatchable: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationPatchable] + + if parameters is not None: + _json = self._serialize.body(parameters, 'ApplicationPatchable') + else: + _json = None + + request = build_update_request_initial( + resource_group_name=resource_group_name, + application_name=application_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('ApplicationPatchable', pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize('ApplicationPatchable', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}"} # type: ignore + + + @distributed_trace + def begin_update( + self, + resource_group_name: str, + application_name: str, + parameters: Optional[_models.ApplicationPatchable] = None, + **kwargs: Any + ) -> LROPoller[_models.ApplicationPatchable]: + """Updates an existing managed application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_name: The name of the managed application. + :type application_name: str + :param parameters: Parameters supplied to update an existing managed application. Default value + is None. + :type parameters: + ~azure.mgmt.managedapplication.v2018_09_01_preview.models.ApplicationPatchable + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ApplicationPatchable or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.managedapplication.v2018_09_01_preview.models.ApplicationPatchable] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationPatchable] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._update_initial( # type: ignore + resource_group_name=resource_group_name, + application_name=application_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('ApplicationPatchable', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}"} # type: ignore + + @distributed_trace + def list_by_resource_group( + self, + resource_group_name: str, + **kwargs: Any + ) -> Iterable[_models.ApplicationListResult]: + """Lists all the applications within a resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ApplicationListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.managedapplication.v2018_09_01_preview.models.ApplicationListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationListResult] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_resource_group.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ApplicationListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications"} # type: ignore + + @distributed_trace + def list_by_subscription( + self, + **kwargs: Any + ) -> Iterable[_models.ApplicationListResult]: + """Lists all the applications within a subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ApplicationListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.managedapplication.v2018_09_01_preview.models.ApplicationListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationListResult] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ApplicationListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Solutions/applications"} # type: ignore + + @distributed_trace + def get_by_id( + self, + application_id: str, + **kwargs: Any + ) -> Optional[_models.Application]: + """Gets the managed application. + + :param application_id: The fully qualified ID of the managed application, including the managed + application name and the managed application resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/Microsoft.Solutions/applications/{application-name}. + :type application_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Application, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2018_09_01_preview.models.Application or None + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.Application]] + + + request = build_get_by_id_request( + application_id=application_id, + api_version=api_version, + template_url=self.get_by_id.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('Application', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_by_id.metadata = {'url': "/{applicationId}"} # type: ignore + + + def _delete_by_id_initial( # pylint: disable=inconsistent-return-statements + self, + application_id: str, + **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_by_id_request_initial( + application_id=application_id, + api_version=api_version, + template_url=self._delete_by_id_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_by_id_initial.metadata = {'url': "/{applicationId}"} # type: ignore + + + @distributed_trace + def begin_delete_by_id( # pylint: disable=inconsistent-return-statements + self, + application_id: str, + **kwargs: Any + ) -> LROPoller[None]: + """Deletes the managed application. + + :param application_id: The fully qualified ID of the managed application, including the managed + application name and the managed application resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/Microsoft.Solutions/applications/{application-name}. + :type application_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._delete_by_id_initial( # type: ignore + application_id=application_id, + api_version=api_version, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete_by_id.metadata = {'url': "/{applicationId}"} # type: ignore + + def _create_or_update_by_id_initial( + self, + application_id: str, + parameters: _models.Application, + **kwargs: Any + ) -> _models.Application: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Application] + + _json = self._serialize.body(parameters, 'Application') + + request = build_create_or_update_by_id_request_initial( + application_id=application_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._create_or_update_by_id_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('Application', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('Application', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_by_id_initial.metadata = {'url': "/{applicationId}"} # type: ignore + + + @distributed_trace + def begin_create_or_update_by_id( + self, + application_id: str, + parameters: _models.Application, + **kwargs: Any + ) -> LROPoller[_models.Application]: + """Creates or updates a managed application. + + :param application_id: The fully qualified ID of the managed application, including the managed + application name and the managed application resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/Microsoft.Solutions/applications/{application-name}. + :type application_id: str + :param parameters: Parameters supplied to the create or update a managed application. + :type parameters: ~azure.mgmt.managedapplication.v2018_09_01_preview.models.Application + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Application or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.managedapplication.v2018_09_01_preview.models.Application] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Application] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._create_or_update_by_id_initial( # type: ignore + application_id=application_id, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('Application', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update_by_id.metadata = {'url': "/{applicationId}"} # type: ignore + + def _update_by_id_initial( + self, + application_id: str, + parameters: Optional[_models.ApplicationPatchable] = None, + **kwargs: Any + ) -> _models.ApplicationPatchable: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationPatchable] + + if parameters is not None: + _json = self._serialize.body(parameters, 'ApplicationPatchable') + else: + _json = None + + request = build_update_by_id_request_initial( + application_id=application_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._update_by_id_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('ApplicationPatchable', pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize('ApplicationPatchable', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _update_by_id_initial.metadata = {'url': "/{applicationId}"} # type: ignore + + + @distributed_trace + def begin_update_by_id( + self, + application_id: str, + parameters: Optional[_models.ApplicationPatchable] = None, + **kwargs: Any + ) -> LROPoller[_models.ApplicationPatchable]: + """Updates an existing managed application. + + :param application_id: The fully qualified ID of the managed application, including the managed + application name and the managed application resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/Microsoft.Solutions/applications/{application-name}. + :type application_id: str + :param parameters: Parameters supplied to update an existing managed application. Default value + is None. + :type parameters: + ~azure.mgmt.managedapplication.v2018_09_01_preview.models.ApplicationPatchable + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ApplicationPatchable or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.managedapplication.v2018_09_01_preview.models.ApplicationPatchable] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationPatchable] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._update_by_id_initial( # type: ignore + application_id=application_id, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('ApplicationPatchable', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_update_by_id.metadata = {'url': "/{applicationId}"} # type: ignore + + def _refresh_permissions_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + application_name: str, + **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_refresh_permissions_request_initial( + resource_group_name=resource_group_name, + application_name=application_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._refresh_permissions_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _refresh_permissions_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}/refreshPermissions"} # type: ignore + + + @distributed_trace + def begin_refresh_permissions( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + application_name: str, + **kwargs: Any + ) -> LROPoller[None]: + """Refresh Permissions for application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_name: The name of the managed application. + :type application_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._refresh_permissions_initial( # type: ignore + resource_group_name=resource_group_name, + application_name=application_name, + api_version=api_version, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'location'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_refresh_permissions.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}/refreshPermissions"} # type: ignore + + def _update_access_initial( + self, + resource_group_name: str, + application_name: str, + parameters: _models.UpdateAccessDefinition, + **kwargs: Any + ) -> Optional[_models.UpdateAccessDefinition]: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.UpdateAccessDefinition]] + + _json = self._serialize.body(parameters, 'UpdateAccessDefinition') + + request = build_update_access_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + application_name=application_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._update_access_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 202: + deserialized = self._deserialize('UpdateAccessDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _update_access_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}/updateAccess"} # type: ignore + + + @distributed_trace + def begin_update_access( + self, + resource_group_name: str, + application_name: str, + parameters: _models.UpdateAccessDefinition, + **kwargs: Any + ) -> LROPoller[_models.UpdateAccessDefinition]: + """Update access for application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_name: The name of the managed application. + :type application_name: str + :param parameters: Request body parameters to update access. + :type parameters: + ~azure.mgmt.managedapplication.v2018_09_01_preview.models.UpdateAccessDefinition + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either UpdateAccessDefinition or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.managedapplication.v2018_09_01_preview.models.UpdateAccessDefinition] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.UpdateAccessDefinition] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._update_access_initial( # type: ignore + resource_group_name=resource_group_name, + application_name=application_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('UpdateAccessDefinition', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'location'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_update_access.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}/updateAccess"} # type: ignore + + @distributed_trace + def list_tokens( + self, + resource_group_name: str, + application_name: str, + parameters: _models.ListTokenRequest, + **kwargs: Any + ) -> _models.ManagedIdentityTokenResult: + """List tokens for application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_name: The name of the managed application. + :type application_name: str + :param parameters: Request body parameters to list tokens. + :type parameters: ~azure.mgmt.managedapplication.v2018_09_01_preview.models.ListTokenRequest + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ManagedIdentityTokenResult, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2018_09_01_preview.models.ManagedIdentityTokenResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ManagedIdentityTokenResult] + + _json = self._serialize.body(parameters, 'ListTokenRequest') + + request = build_list_tokens_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + application_name=application_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.list_tokens.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ManagedIdentityTokenResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_tokens.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}/listTokens"} # type: ignore + diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_09_01_preview/operations/_jit_requests_operations.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_09_01_preview/operations/_jit_requests_operations.py new file mode 100644 index 000000000000..5b68a1046fd1 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_09_01_preview/operations/_jit_requests_operations.py @@ -0,0 +1,739 @@ +# 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, Union, cast + +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.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from .._vendor import MixinABC, _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_request( + resource_group_name: str, + jit_request_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/jitRequests/{jitRequestName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "jitRequestName": _SERIALIZER.url("jit_request_name", jit_request_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_create_or_update_request_initial( + resource_group_name: str, + jit_request_name: str, + subscription_id: str, + *, + json: Optional[_models.JitRequestDefinition] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/jitRequests/{jitRequestName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "jitRequestName": _SERIALIZER.url("jit_request_name", jit_request_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_update_request( + resource_group_name: str, + jit_request_name: str, + subscription_id: str, + *, + json: Optional[_models.JitRequestPatchable] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/jitRequests/{jitRequestName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "jitRequestName": _SERIALIZER.url("jit_request_name", jit_request_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request( + resource_group_name: str, + jit_request_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/jitRequests/{jitRequestName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "jitRequestName": _SERIALIZER.url("jit_request_name", jit_request_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_list_by_subscription_request( + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Solutions/jitRequests") + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_list_by_resource_group_request( + resource_group_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/jitRequests") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + +class JitRequestsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.managedapplication.v2018_09_01_preview.ApplicationClient`'s + :attr:`jit_requests` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + + @distributed_trace + def get( + self, + resource_group_name: str, + jit_request_name: str, + **kwargs: Any + ) -> Optional[_models.JitRequestDefinition]: + """Gets the JIT request. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param jit_request_name: The name of the JIT request. + :type jit_request_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JitRequestDefinition, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2018_09_01_preview.models.JitRequestDefinition or None + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.JitRequestDefinition]] + + + request = build_get_request( + resource_group_name=resource_group_name, + jit_request_name=jit_request_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('JitRequestDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/jitRequests/{jitRequestName}"} # type: ignore + + + def _create_or_update_initial( + self, + resource_group_name: str, + jit_request_name: str, + parameters: _models.JitRequestDefinition, + **kwargs: Any + ) -> _models.JitRequestDefinition: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.JitRequestDefinition] + + _json = self._serialize.body(parameters, 'JitRequestDefinition') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + jit_request_name=jit_request_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('JitRequestDefinition', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('JitRequestDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/jitRequests/{jitRequestName}"} # type: ignore + + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + jit_request_name: str, + parameters: _models.JitRequestDefinition, + **kwargs: Any + ) -> LROPoller[_models.JitRequestDefinition]: + """Creates or updates the JIT request. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param jit_request_name: The name of the JIT request. + :type jit_request_name: str + :param parameters: Parameters supplied to the update JIT request. + :type parameters: + ~azure.mgmt.managedapplication.v2018_09_01_preview.models.JitRequestDefinition + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either JitRequestDefinition or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.managedapplication.v2018_09_01_preview.models.JitRequestDefinition] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.JitRequestDefinition] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._create_or_update_initial( # type: ignore + resource_group_name=resource_group_name, + jit_request_name=jit_request_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('JitRequestDefinition', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/jitRequests/{jitRequestName}"} # type: ignore + + @distributed_trace + def update( + self, + resource_group_name: str, + jit_request_name: str, + parameters: _models.JitRequestPatchable, + **kwargs: Any + ) -> _models.JitRequestDefinition: + """Updates the JIT request. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param jit_request_name: The name of the JIT request. + :type jit_request_name: str + :param parameters: Parameters supplied to the update JIT request. + :type parameters: ~azure.mgmt.managedapplication.v2018_09_01_preview.models.JitRequestPatchable + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JitRequestDefinition, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2018_09_01_preview.models.JitRequestDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.JitRequestDefinition] + + _json = self._serialize.body(parameters, 'JitRequestPatchable') + + request = build_update_request( + resource_group_name=resource_group_name, + jit_request_name=jit_request_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('JitRequestDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/jitRequests/{jitRequestName}"} # type: ignore + + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + jit_request_name: str, + **kwargs: Any + ) -> None: + """Deletes the JIT request. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param jit_request_name: The name of the JIT request. + :type jit_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 + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_request( + resource_group_name=resource_group_name, + jit_request_name=jit_request_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/jitRequests/{jitRequestName}"} # type: ignore + + + @distributed_trace + def list_by_subscription( + self, + **kwargs: Any + ) -> _models.JitRequestDefinitionListResult: + """Lists all JIT requests within the subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JitRequestDefinitionListResult, or the result of cls(response) + :rtype: + ~azure.mgmt.managedapplication.v2018_09_01_preview.models.JitRequestDefinitionListResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.JitRequestDefinitionListResult] + + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('JitRequestDefinitionListResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Solutions/jitRequests"} # type: ignore + + + @distributed_trace + def list_by_resource_group( + self, + resource_group_name: str, + **kwargs: Any + ) -> _models.JitRequestDefinitionListResult: + """Lists all JIT requests within the 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: JitRequestDefinitionListResult, or the result of cls(response) + :rtype: + ~azure.mgmt.managedapplication.v2018_09_01_preview.models.JitRequestDefinitionListResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.JitRequestDefinitionListResult] + + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_resource_group.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('JitRequestDefinitionListResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/jitRequests"} # type: ignore + diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_09_01_preview/operations/_patch.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_09_01_preview/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_09_01_preview/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_09_01_preview/py.typed b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_09_01_preview/py.typed new file mode 100644 index 000000000000..e5aff4f83af8 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2018_09_01_preview/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2019_07_01/__init__.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2019_07_01/__init__.py new file mode 100644 index 000000000000..2e61ca12e56a --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2019_07_01/__init__.py @@ -0,0 +1,23 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._application_client import ApplicationClient +from ._version import VERSION + +__version__ = VERSION + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk +__all__ = ['ApplicationClient'] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2019_07_01/_application_client.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2019_07_01/_application_client.py new file mode 100644 index 000000000000..f1a39d110fc6 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2019_07_01/_application_client.py @@ -0,0 +1,112 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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 ApplicationClientConfiguration +from .operations import ApplicationClientOperationsMixin, ApplicationDefinitionsOperations, ApplicationsOperations, JitRequestsOperations + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential + +class ApplicationClient(ApplicationClientOperationsMixin): + """ARM applications. + + :ivar applications: ApplicationsOperations operations + :vartype applications: + azure.mgmt.managedapplication.v2019_07_01.operations.ApplicationsOperations + :ivar application_definitions: ApplicationDefinitionsOperations operations + :vartype application_definitions: + azure.mgmt.managedapplication.v2019_07_01.operations.ApplicationDefinitionsOperations + :ivar jit_requests: JitRequestsOperations operations + :vartype jit_requests: + azure.mgmt.managedapplication.v2019_07_01.operations.JitRequestsOperations + :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 "2019-07-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + """ + + def __init__( + self, + credential: "TokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = ApplicationClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.applications = ApplicationsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.application_definitions = ApplicationDefinitionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.jit_requests = JitRequestsOperations( + 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: () -> ApplicationClient + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (Any) -> None + self._client.__exit__(*exc_details) diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2019_07_01/_configuration.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2019_07_01/_configuration.py new file mode 100644 index 000000000000..a37c0e90149b --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2019_07_01/_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 ApplicationClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes + """Configuration for ApplicationClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials.TokenCredential + :param subscription_id: The ID of the target subscription. + :type subscription_id: str + :keyword api_version: Api Version. Default value is "2019-07-01". 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(ApplicationClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2019-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.") + + 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-managedapplication/{}'.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/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2019_07_01/_metadata.json b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2019_07_01/_metadata.json new file mode 100644 index 000000000000..e742ba6b493d --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2019_07_01/_metadata.json @@ -0,0 +1,123 @@ +{ + "chosen_version": "2019-07-01", + "total_api_version_list": ["2019-07-01"], + "client": { + "name": "ApplicationClient", + "filename": "_application_client", + "description": "ARM applications.", + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": null, + "azure_arm": true, + "has_lro_operations": true, + "client_side_validation": false, + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ApplicationClientConfiguration\"], \"._operations_mixin\": [\"ApplicationClientOperationsMixin\"]}, \"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\": [\"ApplicationClientConfiguration\"], \"._operations_mixin\": [\"ApplicationClientOperationsMixin\"]}, \"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": { + "applications": "ApplicationsOperations", + "application_definitions": "ApplicationDefinitionsOperations", + "jit_requests": "JitRequestsOperations" + }, + "operation_mixins": { + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Iterable\"]}, \"azurecore\": {\"azure.core.paging\": [\"ItemPaged\"]}}, \"regular\": {\"local\": {\".\": [[\"models\", \"_models\"]]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"AsyncIterable\"]}, \"azurecore\": {\"azure.core.async_paging\": [\"AsyncItemPaged\"]}}, \"regular\": {\"local\": {\"..\": [[\"models\", \"_models\"]]}}}", + "operations": { + "list_operations" : { + "sync": { + "signature": "def list_operations(\n self,\n **kwargs # type: Any\n):\n # type: (...) -\u003e Iterable[_models.OperationListResult]\n", + "doc": "\"\"\"Lists all of the available Microsoft.Solutions REST API operations.\n\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: An iterator like instance of either OperationListResult or the result of cls(response)\n:rtype:\n ~azure.core.paging.ItemPaged[~azure.mgmt.managedapplication.v2019_07_01.models.OperationListResult]\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"", + "call": "**kwargs" + }, + "async": { + "coroutine": false, + "signature": "def list_operations(\n self,\n **kwargs: Any\n) -\u003e AsyncIterable[_models.OperationListResult]:\n", + "doc": "\"\"\"Lists all of the available Microsoft.Solutions REST API operations.\n\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: An iterator like instance of either OperationListResult or the result of cls(response)\n:rtype:\n ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.managedapplication.v2019_07_01.models.OperationListResult]\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"", + "call": "**kwargs" + } + } + } + } +} \ No newline at end of file diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2019_07_01/_patch.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2019_07_01/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2019_07_01/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2019_07_01/_vendor.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2019_07_01/_vendor.py new file mode 100644 index 000000000000..bf1845cabc0f --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2019_07_01/_vendor.py @@ -0,0 +1,45 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from abc import ABC +from typing import TYPE_CHECKING + +from azure.core.pipeline.transport import HttpRequest + +from ._configuration import ApplicationClientConfiguration + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from msrest import Deserializer, Serializer + + from azure.core import PipelineClient + +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) + +class MixinABC(ABC): + """DO NOT use this class. It is for internal typing use only.""" + _client: "PipelineClient" + _config: ApplicationClientConfiguration + _serialize: "Serializer" + _deserialize: "Deserializer" diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2019_07_01/_version.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2019_07_01/_version.py new file mode 100644 index 000000000000..e5754a47ce68 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2019_07_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/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2019_07_01/aio/__init__.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2019_07_01/aio/__init__.py new file mode 100644 index 000000000000..c90626a31421 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2019_07_01/aio/__init__.py @@ -0,0 +1,20 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._application_client import ApplicationClient + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk +__all__ = ['ApplicationClient'] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2019_07_01/aio/_application_client.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2019_07_01/aio/_application_client.py new file mode 100644 index 000000000000..5630832fc244 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2019_07_01/aio/_application_client.py @@ -0,0 +1,109 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# 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 ApplicationClientConfiguration +from .operations import ApplicationClientOperationsMixin, ApplicationDefinitionsOperations, ApplicationsOperations, JitRequestsOperations + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + +class ApplicationClient(ApplicationClientOperationsMixin): + """ARM applications. + + :ivar applications: ApplicationsOperations operations + :vartype applications: + azure.mgmt.managedapplication.v2019_07_01.aio.operations.ApplicationsOperations + :ivar application_definitions: ApplicationDefinitionsOperations operations + :vartype application_definitions: + azure.mgmt.managedapplication.v2019_07_01.aio.operations.ApplicationDefinitionsOperations + :ivar jit_requests: JitRequestsOperations operations + :vartype jit_requests: + azure.mgmt.managedapplication.v2019_07_01.aio.operations.JitRequestsOperations + :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 "2019-07-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = ApplicationClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.applications = ApplicationsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.application_definitions = ApplicationDefinitionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.jit_requests = JitRequestsOperations( + 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) -> "ApplicationClient": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2019_07_01/aio/_configuration.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2019_07_01/aio/_configuration.py new file mode 100644 index 000000000000..66396260913e --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2019_07_01/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 ApplicationClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes + """Configuration for ApplicationClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :param subscription_id: The ID of the target subscription. + :type subscription_id: str + :keyword api_version: Api Version. Default value is "2019-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, + **kwargs: Any + ) -> None: + super(ApplicationClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2019-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.") + + 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-managedapplication/{}'.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/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2019_07_01/aio/_patch.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2019_07_01/aio/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2019_07_01/aio/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2019_07_01/aio/_vendor.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2019_07_01/aio/_vendor.py new file mode 100644 index 000000000000..da14e4f71f0e --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2019_07_01/aio/_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 abc import ABC +from typing import TYPE_CHECKING + +from azure.core.pipeline.transport import HttpRequest + +from ._configuration import ApplicationClientConfiguration + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from msrest import Deserializer, Serializer + + from azure.core import AsyncPipelineClient + + +class MixinABC(ABC): + """DO NOT use this class. It is for internal typing use only.""" + _client: "AsyncPipelineClient" + _config: ApplicationClientConfiguration + _serialize: "Serializer" + _deserialize: "Deserializer" diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2019_07_01/aio/operations/__init__.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2019_07_01/aio/operations/__init__.py new file mode 100644 index 000000000000..b93ecbbe65e2 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2019_07_01/aio/operations/__init__.py @@ -0,0 +1,24 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._application_client_operations import ApplicationClientOperationsMixin +from ._applications_operations import ApplicationsOperations +from ._application_definitions_operations import ApplicationDefinitionsOperations +from ._jit_requests_operations import JitRequestsOperations + +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk +__all__ = [ + 'ApplicationClientOperationsMixin', + 'ApplicationsOperations', + 'ApplicationDefinitionsOperations', + 'JitRequestsOperations', +] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2019_07_01/aio/operations/_application_client_operations.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2019_07_01/aio/operations/_application_client_operations.py new file mode 100644 index 000000000000..8aa2e0cf50b7 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2019_07_01/aio/operations/_application_client_operations.py @@ -0,0 +1,105 @@ +# 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.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._application_client_operations import build_list_operations_request +from .._vendor import MixinABC +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class ApplicationClientOperationsMixin(MixinABC): + + @distributed_trace + def list_operations( + self, + **kwargs: Any + ) -> AsyncIterable[_models.OperationListResult]: + """Lists all of the available Microsoft.Solutions REST API operations. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either OperationListResult or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.managedapplication.v2019_07_01.models.OperationListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # 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', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_operations_request( + api_version=api_version, + template_url=self.list_operations.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_operations_request( + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list_operations.metadata = {'url': "/providers/Microsoft.Solutions/operations"} # type: ignore diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2019_07_01/aio/operations/_application_definitions_operations.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2019_07_01/aio/operations/_application_definitions_operations.py new file mode 100644 index 000000000000..72ba37e9d2bb --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2019_07_01/aio/operations/_application_definitions_operations.py @@ -0,0 +1,761 @@ +# 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.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._application_definitions_operations import build_create_or_update_by_id_request, build_create_or_update_request, build_delete_by_id_request, build_delete_request, build_get_by_id_request, build_get_request, build_list_by_resource_group_request, build_list_by_subscription_request, build_update_by_id_request, build_update_request +from .._vendor import MixinABC +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class ApplicationDefinitionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.managedapplication.v2019_07_01.aio.ApplicationClient`'s + :attr:`application_definitions` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + application_definition_name: str, + **kwargs: Any + ) -> Optional[_models.ApplicationDefinition]: + """Gets the managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. + :type application_definition_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ApplicationDefinition, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2019_07_01.models.ApplicationDefinition or None + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.ApplicationDefinition]] + + + request = build_get_request( + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('ApplicationDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore + + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + application_definition_name: str, + **kwargs: Any + ) -> None: + """Deletes the managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition to delete. + :type application_definition_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_request( + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore + + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + application_definition_name: str, + parameters: _models.ApplicationDefinition, + **kwargs: Any + ) -> _models.ApplicationDefinition: + """Create or update managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. + :type application_definition_name: str + :param parameters: Parameters supplied to the create or update an managed application + definition. + :type parameters: ~azure.mgmt.managedapplication.v2019_07_01.models.ApplicationDefinition + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ApplicationDefinition, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2019_07_01.models.ApplicationDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationDefinition] + + _json = self._serialize.body(parameters, 'ApplicationDefinition') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # 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, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('ApplicationDefinition', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('ApplicationDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore + + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + application_definition_name: str, + parameters: _models.ApplicationDefinitionPatchable, + **kwargs: Any + ) -> _models.ApplicationDefinition: + """Updates the managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. + :type application_definition_name: str + :param parameters: Parameters supplied to the update a managed application definition. + :type parameters: + ~azure.mgmt.managedapplication.v2019_07_01.models.ApplicationDefinitionPatchable + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ApplicationDefinition, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2019_07_01.models.ApplicationDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationDefinition] + + _json = self._serialize.body(parameters, 'ApplicationDefinitionPatchable') + + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ApplicationDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore + + + @distributed_trace + def list_by_resource_group( + self, + resource_group_name: str, + **kwargs: Any + ) -> AsyncIterable[_models.ApplicationDefinitionListResult]: + """Lists the managed application definitions in a resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ApplicationDefinitionListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.managedapplication.v2019_07_01.models.ApplicationDefinitionListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationDefinitionListResult] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_resource_group.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ApplicationDefinitionListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions"} # type: ignore + + @distributed_trace + def list_by_subscription( + self, + **kwargs: Any + ) -> AsyncIterable[_models.ApplicationDefinitionListResult]: + """Lists the managed application definitions in a subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ApplicationDefinitionListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.managedapplication.v2019_07_01.models.ApplicationDefinitionListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationDefinitionListResult] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ApplicationDefinitionListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Solutions/applicationDefinitions"} # type: ignore + + @distributed_trace_async + async def get_by_id( + self, + resource_group_name: str, + application_definition_name: str, + **kwargs: Any + ) -> Optional[_models.ApplicationDefinition]: + """Gets the managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. + :type application_definition_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ApplicationDefinition, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2019_07_01.models.ApplicationDefinition or None + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.ApplicationDefinition]] + + + request = build_get_by_id_request( + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_by_id.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('ApplicationDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_by_id.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore + + + @distributed_trace_async + async def delete_by_id( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + application_definition_name: str, + **kwargs: Any + ) -> None: + """Deletes the managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. + :type application_definition_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_by_id_request( + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete_by_id.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete_by_id.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore + + + @distributed_trace_async + async def create_or_update_by_id( + self, + resource_group_name: str, + application_definition_name: str, + parameters: _models.ApplicationDefinition, + **kwargs: Any + ) -> _models.ApplicationDefinition: + """Creates or updates a managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. + :type application_definition_name: str + :param parameters: Parameters supplied to the create or update a managed application + definition. + :type parameters: ~azure.mgmt.managedapplication.v2019_07_01.models.ApplicationDefinition + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ApplicationDefinition, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2019_07_01.models.ApplicationDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationDefinition] + + _json = self._serialize.body(parameters, 'ApplicationDefinition') + + request = build_create_or_update_by_id_request( + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + 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'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # 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, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('ApplicationDefinition', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('ApplicationDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_or_update_by_id.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore + + + @distributed_trace_async + async def update_by_id( + self, + resource_group_name: str, + application_definition_name: str, + parameters: _models.ApplicationDefinitionPatchable, + **kwargs: Any + ) -> _models.ApplicationDefinition: + """Updates the managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. + :type application_definition_name: str + :param parameters: Parameters supplied to the update a managed application definition. + :type parameters: + ~azure.mgmt.managedapplication.v2019_07_01.models.ApplicationDefinitionPatchable + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ApplicationDefinition, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2019_07_01.models.ApplicationDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationDefinition] + + _json = self._serialize.body(parameters, 'ApplicationDefinitionPatchable') + + request = build_update_by_id_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.update_by_id.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ApplicationDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + update_by_id.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore + diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2019_07_01/aio/operations/_applications_operations.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2019_07_01/aio/operations/_applications_operations.py new file mode 100644 index 000000000000..057cafa0d0bc --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2019_07_01/aio/operations/_applications_operations.py @@ -0,0 +1,1545 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union, cast + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._applications_operations import build_create_or_update_by_id_request_initial, build_create_or_update_request_initial, build_delete_by_id_request_initial, build_delete_request_initial, build_get_by_id_request, build_get_request, build_list_allowed_upgrade_plans_request, build_list_by_resource_group_request, build_list_by_subscription_request, build_list_tokens_request, build_refresh_permissions_request_initial, build_update_access_request_initial, build_update_by_id_request_initial, build_update_request_initial +from .._vendor import MixinABC +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class ApplicationsOperations: # pylint: disable=too-many-public-methods + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.managedapplication.v2019_07_01.aio.ApplicationClient`'s + :attr:`applications` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + application_name: str, + **kwargs: Any + ) -> Optional[_models.Application]: + """Gets the managed application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_name: The name of the managed application. + :type application_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Application, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2019_07_01.models.Application or None + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.Application]] + + + request = build_get_request( + resource_group_name=resource_group_name, + application_name=application_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('Application', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}"} # type: ignore + + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + application_name: str, + **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + application_name=application_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}"} # type: ignore + + + @distributed_trace_async + async def begin_delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + application_name: str, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes the managed application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_name: The name of the managed application. + :type application_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._delete_initial( # type: ignore + resource_group_name=resource_group_name, + application_name=application_name, + api_version=api_version, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}"} # type: ignore + + async def _create_or_update_initial( + self, + resource_group_name: str, + application_name: str, + parameters: _models.Application, + **kwargs: Any + ) -> _models.Application: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Application] + + _json = self._serialize.body(parameters, 'Application') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + application_name=application_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('Application', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('Application', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}"} # type: ignore + + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + application_name: str, + parameters: _models.Application, + **kwargs: Any + ) -> AsyncLROPoller[_models.Application]: + """Creates or updates a managed application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_name: The name of the managed application. + :type application_name: str + :param parameters: Parameters supplied to the create or update a managed application. + :type parameters: ~azure.mgmt.managedapplication.v2019_07_01.models.Application + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either Application or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.managedapplication.v2019_07_01.models.Application] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Application] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._create_or_update_initial( # type: ignore + resource_group_name=resource_group_name, + application_name=application_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('Application', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}"} # type: ignore + + async def _update_initial( + self, + resource_group_name: str, + application_name: str, + parameters: Optional[_models.ApplicationPatchable] = None, + **kwargs: Any + ) -> _models.ApplicationPatchable: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationPatchable] + + if parameters is not None: + _json = self._serialize.body(parameters, 'ApplicationPatchable') + else: + _json = None + + request = build_update_request_initial( + resource_group_name=resource_group_name, + application_name=application_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('ApplicationPatchable', pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize('ApplicationPatchable', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}"} # type: ignore + + + @distributed_trace_async + async def begin_update( + self, + resource_group_name: str, + application_name: str, + parameters: Optional[_models.ApplicationPatchable] = None, + **kwargs: Any + ) -> AsyncLROPoller[_models.ApplicationPatchable]: + """Updates an existing managed application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_name: The name of the managed application. + :type application_name: str + :param parameters: Parameters supplied to update an existing managed application. Default value + is None. + :type parameters: ~azure.mgmt.managedapplication.v2019_07_01.models.ApplicationPatchable + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ApplicationPatchable or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.managedapplication.v2019_07_01.models.ApplicationPatchable] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationPatchable] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._update_initial( # type: ignore + resource_group_name=resource_group_name, + application_name=application_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('ApplicationPatchable', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}"} # type: ignore + + @distributed_trace + def list_by_resource_group( + self, + resource_group_name: str, + **kwargs: Any + ) -> AsyncIterable[_models.ApplicationListResult]: + """Lists all the applications within a resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ApplicationListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.managedapplication.v2019_07_01.models.ApplicationListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationListResult] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_resource_group.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ApplicationListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications"} # type: ignore + + @distributed_trace + def list_by_subscription( + self, + **kwargs: Any + ) -> AsyncIterable[_models.ApplicationListResult]: + """Lists all the applications within a subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ApplicationListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.managedapplication.v2019_07_01.models.ApplicationListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationListResult] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ApplicationListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Solutions/applications"} # type: ignore + + @distributed_trace_async + async def get_by_id( + self, + application_id: str, + **kwargs: Any + ) -> Optional[_models.Application]: + """Gets the managed application. + + :param application_id: The fully qualified ID of the managed application, including the managed + application name and the managed application resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/Microsoft.Solutions/applications/{application-name}. + :type application_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Application, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2019_07_01.models.Application or None + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.Application]] + + + request = build_get_by_id_request( + application_id=application_id, + api_version=api_version, + template_url=self.get_by_id.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('Application', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_by_id.metadata = {'url': "/{applicationId}"} # type: ignore + + + async def _delete_by_id_initial( # pylint: disable=inconsistent-return-statements + self, + application_id: str, + **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_by_id_request_initial( + application_id=application_id, + api_version=api_version, + template_url=self._delete_by_id_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_by_id_initial.metadata = {'url': "/{applicationId}"} # type: ignore + + + @distributed_trace_async + async def begin_delete_by_id( # pylint: disable=inconsistent-return-statements + self, + application_id: str, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes the managed application. + + :param application_id: The fully qualified ID of the managed application, including the managed + application name and the managed application resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/Microsoft.Solutions/applications/{application-name}. + :type application_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._delete_by_id_initial( # type: ignore + application_id=application_id, + api_version=api_version, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete_by_id.metadata = {'url': "/{applicationId}"} # type: ignore + + async def _create_or_update_by_id_initial( + self, + application_id: str, + parameters: _models.Application, + **kwargs: Any + ) -> _models.Application: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Application] + + _json = self._serialize.body(parameters, 'Application') + + request = build_create_or_update_by_id_request_initial( + application_id=application_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._create_or_update_by_id_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('Application', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('Application', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_by_id_initial.metadata = {'url': "/{applicationId}"} # type: ignore + + + @distributed_trace_async + async def begin_create_or_update_by_id( + self, + application_id: str, + parameters: _models.Application, + **kwargs: Any + ) -> AsyncLROPoller[_models.Application]: + """Creates or updates a managed application. + + :param application_id: The fully qualified ID of the managed application, including the managed + application name and the managed application resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/Microsoft.Solutions/applications/{application-name}. + :type application_id: str + :param parameters: Parameters supplied to the create or update a managed application. + :type parameters: ~azure.mgmt.managedapplication.v2019_07_01.models.Application + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either Application or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.managedapplication.v2019_07_01.models.Application] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Application] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._create_or_update_by_id_initial( # type: ignore + application_id=application_id, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('Application', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update_by_id.metadata = {'url': "/{applicationId}"} # type: ignore + + async def _update_by_id_initial( + self, + application_id: str, + parameters: Optional[_models.ApplicationPatchable] = None, + **kwargs: Any + ) -> _models.ApplicationPatchable: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationPatchable] + + if parameters is not None: + _json = self._serialize.body(parameters, 'ApplicationPatchable') + else: + _json = None + + request = build_update_by_id_request_initial( + application_id=application_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._update_by_id_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('ApplicationPatchable', pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize('ApplicationPatchable', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _update_by_id_initial.metadata = {'url': "/{applicationId}"} # type: ignore + + + @distributed_trace_async + async def begin_update_by_id( + self, + application_id: str, + parameters: Optional[_models.ApplicationPatchable] = None, + **kwargs: Any + ) -> AsyncLROPoller[_models.ApplicationPatchable]: + """Updates an existing managed application. + + :param application_id: The fully qualified ID of the managed application, including the managed + application name and the managed application resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/Microsoft.Solutions/applications/{application-name}. + :type application_id: str + :param parameters: Parameters supplied to update an existing managed application. Default value + is None. + :type parameters: ~azure.mgmt.managedapplication.v2019_07_01.models.ApplicationPatchable + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ApplicationPatchable or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.managedapplication.v2019_07_01.models.ApplicationPatchable] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationPatchable] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._update_by_id_initial( # type: ignore + application_id=application_id, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('ApplicationPatchable', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_update_by_id.metadata = {'url': "/{applicationId}"} # type: ignore + + async def _refresh_permissions_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + application_name: str, + **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_refresh_permissions_request_initial( + resource_group_name=resource_group_name, + application_name=application_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._refresh_permissions_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _refresh_permissions_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}/refreshPermissions"} # type: ignore + + + @distributed_trace_async + async def begin_refresh_permissions( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + application_name: str, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Refresh Permissions for application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_name: The name of the managed application. + :type application_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._refresh_permissions_initial( # type: ignore + resource_group_name=resource_group_name, + application_name=application_name, + api_version=api_version, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'location'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_refresh_permissions.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}/refreshPermissions"} # type: ignore + + @distributed_trace_async + async def list_allowed_upgrade_plans( + self, + resource_group_name: str, + application_name: str, + **kwargs: Any + ) -> _models.AllowedUpgradePlansResult: + """List allowed upgrade plans for application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_name: The name of the managed application. + :type application_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AllowedUpgradePlansResult, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2019_07_01.models.AllowedUpgradePlansResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AllowedUpgradePlansResult] + + + request = build_list_allowed_upgrade_plans_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + application_name=application_name, + api_version=api_version, + template_url=self.list_allowed_upgrade_plans.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('AllowedUpgradePlansResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_allowed_upgrade_plans.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}/listAllowedUpgradePlans"} # type: ignore + + + async def _update_access_initial( + self, + resource_group_name: str, + application_name: str, + parameters: _models.UpdateAccessDefinition, + **kwargs: Any + ) -> Optional[_models.UpdateAccessDefinition]: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.UpdateAccessDefinition]] + + _json = self._serialize.body(parameters, 'UpdateAccessDefinition') + + request = build_update_access_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + application_name=application_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._update_access_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 202: + deserialized = self._deserialize('UpdateAccessDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _update_access_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}/updateAccess"} # type: ignore + + + @distributed_trace_async + async def begin_update_access( + self, + resource_group_name: str, + application_name: str, + parameters: _models.UpdateAccessDefinition, + **kwargs: Any + ) -> AsyncLROPoller[_models.UpdateAccessDefinition]: + """Update access for application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_name: The name of the managed application. + :type application_name: str + :param parameters: Request body parameters to list tokens. + :type parameters: ~azure.mgmt.managedapplication.v2019_07_01.models.UpdateAccessDefinition + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either UpdateAccessDefinition or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.managedapplication.v2019_07_01.models.UpdateAccessDefinition] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.UpdateAccessDefinition] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._update_access_initial( # type: ignore + resource_group_name=resource_group_name, + application_name=application_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('UpdateAccessDefinition', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'location'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_update_access.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}/updateAccess"} # type: ignore + + @distributed_trace_async + async def list_tokens( + self, + resource_group_name: str, + application_name: str, + parameters: _models.ListTokenRequest, + **kwargs: Any + ) -> _models.ManagedIdentityTokenResult: + """List tokens for application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_name: The name of the managed application. + :type application_name: str + :param parameters: Request body parameters to list tokens. + :type parameters: ~azure.mgmt.managedapplication.v2019_07_01.models.ListTokenRequest + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ManagedIdentityTokenResult, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2019_07_01.models.ManagedIdentityTokenResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ManagedIdentityTokenResult] + + _json = self._serialize.body(parameters, 'ListTokenRequest') + + request = build_list_tokens_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + application_name=application_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.list_tokens.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ManagedIdentityTokenResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_tokens.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}/listTokens"} # type: ignore + diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2019_07_01/aio/operations/_jit_requests_operations.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2019_07_01/aio/operations/_jit_requests_operations.py new file mode 100644 index 000000000000..45522bfefa34 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2019_07_01/aio/operations/_jit_requests_operations.py @@ -0,0 +1,502 @@ +# 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, Union, cast + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._jit_requests_operations import build_create_or_update_request_initial, build_delete_request, build_get_request, build_list_by_resource_group_request, build_list_by_subscription_request, build_update_request +from .._vendor import MixinABC +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class JitRequestsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.managedapplication.v2019_07_01.aio.ApplicationClient`'s + :attr:`jit_requests` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + jit_request_name: str, + **kwargs: Any + ) -> Optional[_models.JitRequestDefinition]: + """Gets the JIT request. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param jit_request_name: The name of the JIT request. + :type jit_request_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JitRequestDefinition, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2019_07_01.models.JitRequestDefinition or None + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.JitRequestDefinition]] + + + request = build_get_request( + resource_group_name=resource_group_name, + jit_request_name=jit_request_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('JitRequestDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/jitRequests/{jitRequestName}"} # type: ignore + + + async def _create_or_update_initial( + self, + resource_group_name: str, + jit_request_name: str, + parameters: _models.JitRequestDefinition, + **kwargs: Any + ) -> _models.JitRequestDefinition: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.JitRequestDefinition] + + _json = self._serialize.body(parameters, 'JitRequestDefinition') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + jit_request_name=jit_request_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('JitRequestDefinition', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('JitRequestDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/jitRequests/{jitRequestName}"} # type: ignore + + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + jit_request_name: str, + parameters: _models.JitRequestDefinition, + **kwargs: Any + ) -> AsyncLROPoller[_models.JitRequestDefinition]: + """Creates or updates the JIT request. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param jit_request_name: The name of the JIT request. + :type jit_request_name: str + :param parameters: Parameters supplied to the update JIT request. + :type parameters: ~azure.mgmt.managedapplication.v2019_07_01.models.JitRequestDefinition + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either JitRequestDefinition or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.managedapplication.v2019_07_01.models.JitRequestDefinition] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.JitRequestDefinition] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._create_or_update_initial( # type: ignore + resource_group_name=resource_group_name, + jit_request_name=jit_request_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('JitRequestDefinition', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/jitRequests/{jitRequestName}"} # type: ignore + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + jit_request_name: str, + parameters: _models.JitRequestPatchable, + **kwargs: Any + ) -> _models.JitRequestDefinition: + """Updates the JIT request. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param jit_request_name: The name of the JIT request. + :type jit_request_name: str + :param parameters: Parameters supplied to the update JIT request. + :type parameters: ~azure.mgmt.managedapplication.v2019_07_01.models.JitRequestPatchable + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JitRequestDefinition, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2019_07_01.models.JitRequestDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.JitRequestDefinition] + + _json = self._serialize.body(parameters, 'JitRequestPatchable') + + request = build_update_request( + resource_group_name=resource_group_name, + jit_request_name=jit_request_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('JitRequestDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/jitRequests/{jitRequestName}"} # type: ignore + + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + jit_request_name: str, + **kwargs: Any + ) -> None: + """Deletes the JIT request. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param jit_request_name: The name of the JIT request. + :type jit_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 + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_request( + resource_group_name=resource_group_name, + jit_request_name=jit_request_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/jitRequests/{jitRequestName}"} # type: ignore + + + @distributed_trace_async + async def list_by_subscription( + self, + **kwargs: Any + ) -> _models.JitRequestDefinitionListResult: + """Lists all JIT requests within the subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JitRequestDefinitionListResult, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2019_07_01.models.JitRequestDefinitionListResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.JitRequestDefinitionListResult] + + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('JitRequestDefinitionListResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Solutions/jitRequests"} # type: ignore + + + @distributed_trace_async + async def list_by_resource_group( + self, + resource_group_name: str, + **kwargs: Any + ) -> _models.JitRequestDefinitionListResult: + """Retrieves all JIT requests within the 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: JitRequestDefinitionListResult, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2019_07_01.models.JitRequestDefinitionListResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.JitRequestDefinitionListResult] + + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_resource_group.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('JitRequestDefinitionListResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/jitRequests"} # type: ignore + diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2019_07_01/aio/operations/_patch.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2019_07_01/aio/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2019_07_01/aio/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2019_07_01/models/__init__.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2019_07_01/models/__init__.py new file mode 100644 index 000000000000..64a1d3d852b9 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2019_07_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 AllowedUpgradePlansResult +from ._models_py3 import Application +from ._models_py3 import ApplicationArtifact +from ._models_py3 import ApplicationAuthorization +from ._models_py3 import ApplicationBillingDetailsDefinition +from ._models_py3 import ApplicationClientDetails +from ._models_py3 import ApplicationDefinition +from ._models_py3 import ApplicationDefinitionArtifact +from ._models_py3 import ApplicationDefinitionListResult +from ._models_py3 import ApplicationDefinitionPatchable +from ._models_py3 import ApplicationDeploymentPolicy +from ._models_py3 import ApplicationJitAccessPolicy +from ._models_py3 import ApplicationListResult +from ._models_py3 import ApplicationManagementPolicy +from ._models_py3 import ApplicationNotificationEndpoint +from ._models_py3 import ApplicationNotificationPolicy +from ._models_py3 import ApplicationPackageContact +from ._models_py3 import ApplicationPackageLockingPolicyDefinition +from ._models_py3 import ApplicationPackageSupportUrls +from ._models_py3 import ApplicationPatchable +from ._models_py3 import ApplicationPolicy +from ._models_py3 import ApplicationPropertiesPatchable +from ._models_py3 import ErrorAdditionalInfo +from ._models_py3 import ErrorDetail +from ._models_py3 import ErrorResponse +from ._models_py3 import GenericResource +from ._models_py3 import Identity +from ._models_py3 import JitApproverDefinition +from ._models_py3 import JitAuthorizationPolicies +from ._models_py3 import JitRequestDefinition +from ._models_py3 import JitRequestDefinitionListResult +from ._models_py3 import JitRequestMetadata +from ._models_py3 import JitRequestPatchable +from ._models_py3 import JitSchedulingPolicy +from ._models_py3 import ListTokenRequest +from ._models_py3 import ManagedIdentityToken +from ._models_py3 import ManagedIdentityTokenResult +from ._models_py3 import Operation +from ._models_py3 import OperationAutoGenerated +from ._models_py3 import OperationDisplay +from ._models_py3 import OperationDisplayAutoGenerated +from ._models_py3 import OperationListResult +from ._models_py3 import Plan +from ._models_py3 import PlanPatchable +from ._models_py3 import Resource +from ._models_py3 import Sku +from ._models_py3 import UpdateAccessDefinition +from ._models_py3 import UserAssignedResourceIdentity + + +from ._application_client_enums import ( + ActionType, + ApplicationArtifactName, + ApplicationArtifactType, + ApplicationDefinitionArtifactName, + ApplicationLockLevel, + ApplicationManagementMode, + DeploymentMode, + JitApprovalMode, + JitApproverType, + JitRequestState, + JitSchedulingType, + Origin, + ProvisioningState, + ResourceIdentityType, + Status, + Substatus, +) +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk +__all__ = [ + 'AllowedUpgradePlansResult', + 'Application', + 'ApplicationArtifact', + 'ApplicationAuthorization', + 'ApplicationBillingDetailsDefinition', + 'ApplicationClientDetails', + 'ApplicationDefinition', + 'ApplicationDefinitionArtifact', + 'ApplicationDefinitionListResult', + 'ApplicationDefinitionPatchable', + 'ApplicationDeploymentPolicy', + 'ApplicationJitAccessPolicy', + 'ApplicationListResult', + 'ApplicationManagementPolicy', + 'ApplicationNotificationEndpoint', + 'ApplicationNotificationPolicy', + 'ApplicationPackageContact', + 'ApplicationPackageLockingPolicyDefinition', + 'ApplicationPackageSupportUrls', + 'ApplicationPatchable', + 'ApplicationPolicy', + 'ApplicationPropertiesPatchable', + 'ErrorAdditionalInfo', + 'ErrorDetail', + 'ErrorResponse', + 'GenericResource', + 'Identity', + 'JitApproverDefinition', + 'JitAuthorizationPolicies', + 'JitRequestDefinition', + 'JitRequestDefinitionListResult', + 'JitRequestMetadata', + 'JitRequestPatchable', + 'JitSchedulingPolicy', + 'ListTokenRequest', + 'ManagedIdentityToken', + 'ManagedIdentityTokenResult', + 'Operation', + 'OperationAutoGenerated', + 'OperationDisplay', + 'OperationDisplayAutoGenerated', + 'OperationListResult', + 'Plan', + 'PlanPatchable', + 'Resource', + 'Sku', + 'UpdateAccessDefinition', + 'UserAssignedResourceIdentity', + 'ActionType', + 'ApplicationArtifactName', + 'ApplicationArtifactType', + 'ApplicationDefinitionArtifactName', + 'ApplicationLockLevel', + 'ApplicationManagementMode', + 'DeploymentMode', + 'JitApprovalMode', + 'JitApproverType', + 'JitRequestState', + 'JitSchedulingType', + 'Origin', + 'ProvisioningState', + 'ResourceIdentityType', + 'Status', + 'Substatus', +] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2019_07_01/models/_application_client_enums.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2019_07_01/models/_application_client_enums.py new file mode 100644 index 000000000000..890f1a84757e --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2019_07_01/models/_application_client_enums.py @@ -0,0 +1,157 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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 azure.core import CaseInsensitiveEnumMeta + + +class ActionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. + """ + + INTERNAL = "Internal" + +class ApplicationArtifactName(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The managed application artifact name. + """ + + NOT_SPECIFIED = "NotSpecified" + VIEW_DEFINITION = "ViewDefinition" + AUTHORIZATIONS = "Authorizations" + CUSTOM_ROLE_DEFINITION = "CustomRoleDefinition" + +class ApplicationArtifactType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The managed application artifact type. + """ + + NOT_SPECIFIED = "NotSpecified" + TEMPLATE = "Template" + CUSTOM = "Custom" + +class ApplicationDefinitionArtifactName(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The managed application artifact name. + """ + + NOT_SPECIFIED = "NotSpecified" + APPLICATION_RESOURCE_TEMPLATE = "ApplicationResourceTemplate" + CREATE_UI_DEFINITION = "CreateUiDefinition" + MAIN_TEMPLATE_PARAMETERS = "MainTemplateParameters" + +class ApplicationLockLevel(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The managed application lock level. + """ + + CAN_NOT_DELETE = "CanNotDelete" + READ_ONLY = "ReadOnly" + NONE = "None" + +class ApplicationManagementMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The management mode. + """ + + NOT_SPECIFIED = "NotSpecified" + UNMANAGED = "Unmanaged" + MANAGED = "Managed" + +class DeploymentMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The deployment mode. + """ + + NOT_SPECIFIED = "NotSpecified" + INCREMENTAL = "Incremental" + COMPLETE = "Complete" + +class JitApprovalMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The Jit approval mode. + """ + + NOT_SPECIFIED = "NotSpecified" + AUTO_APPROVE = "AutoApprove" + MANUAL_APPROVE = "ManualApprove" + +class JitApproverType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The approver type. + """ + + USER = "user" + GROUP = "group" + +class JitRequestState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The JIT request state. + """ + + NOT_SPECIFIED = "NotSpecified" + PENDING = "Pending" + APPROVED = "Approved" + DENIED = "Denied" + FAILED = "Failed" + CANCELED = "Canceled" + EXPIRED = "Expired" + TIMEOUT = "Timeout" + +class JitSchedulingType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The JIT request scheduling type. + """ + + NOT_SPECIFIED = "NotSpecified" + ONCE = "Once" + RECURRING = "Recurring" + +class Origin(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit + logs UX. Default value is "user,system" + """ + + USER = "user" + SYSTEM = "system" + USER_SYSTEM = "user,system" + +class ProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Provisioning status of the managed application. + """ + + NOT_SPECIFIED = "NotSpecified" + ACCEPTED = "Accepted" + RUNNING = "Running" + READY = "Ready" + CREATING = "Creating" + CREATED = "Created" + DELETING = "Deleting" + DELETED = "Deleted" + CANCELED = "Canceled" + FAILED = "Failed" + SUCCEEDED = "Succeeded" + UPDATING = "Updating" + +class ResourceIdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The identity type. + """ + + SYSTEM_ASSIGNED = "SystemAssigned" + USER_ASSIGNED = "UserAssigned" + SYSTEM_ASSIGNED_USER_ASSIGNED = "SystemAssigned, UserAssigned" + NONE = "None" + +class Status(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The JIT status. + """ + + NOT_SPECIFIED = "NotSpecified" + ELEVATE = "Elevate" + REMOVE = "Remove" + +class Substatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The sub status. + """ + + NOT_SPECIFIED = "NotSpecified" + APPROVED = "Approved" + DENIED = "Denied" + FAILED = "Failed" + EXPIRED = "Expired" + TIMEOUT = "Timeout" diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2019_07_01/models/_models_py3.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2019_07_01/models/_models_py3.py new file mode 100644 index 000000000000..78ccae227e17 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2019_07_01/models/_models_py3.py @@ -0,0 +1,2528 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for 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 Any, Dict, List, Optional, TYPE_CHECKING, Union + +from azure.core.exceptions import HttpResponseError +import msrest.serialization + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + import __init__ as _models + + +class AllowedUpgradePlansResult(msrest.serialization.Model): + """The array of plan. + + :ivar value: The array of plans. + :vartype value: list[~azure.mgmt.managedapplication.v2019_07_01.models.Plan] + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Plan]'}, + } + + def __init__( + self, + *, + value: Optional[List["_models.Plan"]] = None, + **kwargs + ): + """ + :keyword value: The array of plans. + :paramtype value: list[~azure.mgmt.managedapplication.v2019_07_01.models.Plan] + """ + super(AllowedUpgradePlansResult, self).__init__(**kwargs) + self.value = value + + +class Resource(msrest.serialization.Model): + """Resource information. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Resource ID. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar location: Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'location': {'key': 'location', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + } + + def __init__( + self, + *, + location: Optional[str] = None, + tags: Optional[Dict[str, str]] = None, + **kwargs + ): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + """ + super(Resource, self).__init__(**kwargs) + self.id = None + self.name = None + self.type = None + self.location = location + self.tags = tags + + +class GenericResource(Resource): + """Resource information. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Resource ID. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar location: Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar managed_by: ID of the resource that manages this resource. + :vartype managed_by: str + :ivar sku: The SKU of the resource. + :vartype sku: ~azure.mgmt.managedapplication.v2019_07_01.models.Sku + """ + + _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'}, + 'location': {'key': 'location', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + 'managed_by': {'key': 'managedBy', 'type': 'str'}, + 'sku': {'key': 'sku', 'type': 'Sku'}, + } + + def __init__( + self, + *, + location: Optional[str] = None, + tags: Optional[Dict[str, str]] = None, + managed_by: Optional[str] = None, + sku: Optional["_models.Sku"] = None, + **kwargs + ): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword managed_by: ID of the resource that manages this resource. + :paramtype managed_by: str + :keyword sku: The SKU of the resource. + :paramtype sku: ~azure.mgmt.managedapplication.v2019_07_01.models.Sku + """ + super(GenericResource, self).__init__(location=location, tags=tags, **kwargs) + self.managed_by = managed_by + self.sku = sku + + +class Application(GenericResource): + """Information about managed application. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar id: Resource ID. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar location: Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar managed_by: ID of the resource that manages this resource. + :vartype managed_by: str + :ivar sku: The SKU of the resource. + :vartype sku: ~azure.mgmt.managedapplication.v2019_07_01.models.Sku + :ivar plan: The plan information. + :vartype plan: ~azure.mgmt.managedapplication.v2019_07_01.models.Plan + :ivar kind: Required. The kind of the managed application. Allowed values are MarketPlace and + ServiceCatalog. + :vartype kind: str + :ivar identity: The identity of the resource. + :vartype identity: ~azure.mgmt.managedapplication.v2019_07_01.models.Identity + :ivar managed_resource_group_id: The managed resource group Id. + :vartype managed_resource_group_id: str + :ivar application_definition_id: The fully qualified path of managed application definition Id. + :vartype application_definition_id: str + :ivar parameters: Name and value pairs that define the managed application parameters. It can + be a JObject or a well formed JSON string. + :vartype parameters: any + :ivar outputs: Name and value pairs that define the managed application outputs. + :vartype outputs: any + :ivar provisioning_state: The managed application provisioning state. Known values are: + "NotSpecified", "Accepted", "Running", "Ready", "Creating", "Created", "Deleting", "Deleted", + "Canceled", "Failed", "Succeeded", "Updating". + :vartype provisioning_state: str or + ~azure.mgmt.managedapplication.v2019_07_01.models.ProvisioningState + :ivar billing_details: The managed application billing details. + :vartype billing_details: + ~azure.mgmt.managedapplication.v2019_07_01.models.ApplicationBillingDetailsDefinition + :ivar jit_access_policy: The managed application Jit access policy. + :vartype jit_access_policy: + ~azure.mgmt.managedapplication.v2019_07_01.models.ApplicationJitAccessPolicy + :ivar publisher_tenant_id: The publisher tenant Id. + :vartype publisher_tenant_id: str + :ivar authorizations: The read-only authorizations property that is retrieved from the + application package. + :vartype authorizations: + list[~azure.mgmt.managedapplication.v2019_07_01.models.ApplicationAuthorization] + :ivar management_mode: The managed application management mode. Known values are: + "NotSpecified", "Unmanaged", "Managed". + :vartype management_mode: str or + ~azure.mgmt.managedapplication.v2019_07_01.models.ApplicationManagementMode + :ivar customer_support: The read-only customer support property that is retrieved from the + application package. + :vartype customer_support: + ~azure.mgmt.managedapplication.v2019_07_01.models.ApplicationPackageContact + :ivar support_urls: The read-only support URLs property that is retrieved from the application + package. + :vartype support_urls: + ~azure.mgmt.managedapplication.v2019_07_01.models.ApplicationPackageSupportUrls + :ivar artifacts: The collection of managed application artifacts. + :vartype artifacts: list[~azure.mgmt.managedapplication.v2019_07_01.models.ApplicationArtifact] + :ivar created_by: The client entity that created the JIT request. + :vartype created_by: ~azure.mgmt.managedapplication.v2019_07_01.models.ApplicationClientDetails + :ivar updated_by: The client entity that last updated the JIT request. + :vartype updated_by: ~azure.mgmt.managedapplication.v2019_07_01.models.ApplicationClientDetails + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'kind': {'required': True, 'pattern': r'^[-\w\._,\(\)]+$'}, + 'outputs': {'readonly': True}, + 'provisioning_state': {'readonly': True}, + 'billing_details': {'readonly': True}, + 'publisher_tenant_id': {'readonly': True}, + 'authorizations': {'readonly': True}, + 'management_mode': {'readonly': True}, + 'customer_support': {'readonly': True}, + 'support_urls': {'readonly': True}, + 'artifacts': {'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'}, + 'location': {'key': 'location', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + 'managed_by': {'key': 'managedBy', 'type': 'str'}, + 'sku': {'key': 'sku', 'type': 'Sku'}, + 'plan': {'key': 'plan', 'type': 'Plan'}, + 'kind': {'key': 'kind', 'type': 'str'}, + 'identity': {'key': 'identity', 'type': 'Identity'}, + 'managed_resource_group_id': {'key': 'properties.managedResourceGroupId', 'type': 'str'}, + 'application_definition_id': {'key': 'properties.applicationDefinitionId', 'type': 'str'}, + 'parameters': {'key': 'properties.parameters', 'type': 'object'}, + 'outputs': {'key': 'properties.outputs', 'type': 'object'}, + 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + 'billing_details': {'key': 'properties.billingDetails', 'type': 'ApplicationBillingDetailsDefinition'}, + 'jit_access_policy': {'key': 'properties.jitAccessPolicy', 'type': 'ApplicationJitAccessPolicy'}, + 'publisher_tenant_id': {'key': 'properties.publisherTenantId', 'type': 'str'}, + 'authorizations': {'key': 'properties.authorizations', 'type': '[ApplicationAuthorization]'}, + 'management_mode': {'key': 'properties.managementMode', 'type': 'str'}, + 'customer_support': {'key': 'properties.customerSupport', 'type': 'ApplicationPackageContact'}, + 'support_urls': {'key': 'properties.supportUrls', 'type': 'ApplicationPackageSupportUrls'}, + 'artifacts': {'key': 'properties.artifacts', 'type': '[ApplicationArtifact]'}, + 'created_by': {'key': 'properties.createdBy', 'type': 'ApplicationClientDetails'}, + 'updated_by': {'key': 'properties.updatedBy', 'type': 'ApplicationClientDetails'}, + } + + def __init__( + self, + *, + kind: str, + location: Optional[str] = None, + tags: Optional[Dict[str, str]] = None, + managed_by: Optional[str] = None, + sku: Optional["_models.Sku"] = None, + plan: Optional["_models.Plan"] = None, + identity: Optional["_models.Identity"] = None, + managed_resource_group_id: Optional[str] = None, + application_definition_id: Optional[str] = None, + parameters: Optional[Any] = None, + jit_access_policy: Optional["_models.ApplicationJitAccessPolicy"] = None, + **kwargs + ): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword managed_by: ID of the resource that manages this resource. + :paramtype managed_by: str + :keyword sku: The SKU of the resource. + :paramtype sku: ~azure.mgmt.managedapplication.v2019_07_01.models.Sku + :keyword plan: The plan information. + :paramtype plan: ~azure.mgmt.managedapplication.v2019_07_01.models.Plan + :keyword kind: Required. The kind of the managed application. Allowed values are MarketPlace + and ServiceCatalog. + :paramtype kind: str + :keyword identity: The identity of the resource. + :paramtype identity: ~azure.mgmt.managedapplication.v2019_07_01.models.Identity + :keyword managed_resource_group_id: The managed resource group Id. + :paramtype managed_resource_group_id: str + :keyword application_definition_id: The fully qualified path of managed application definition + Id. + :paramtype application_definition_id: str + :keyword parameters: Name and value pairs that define the managed application parameters. It + can be a JObject or a well formed JSON string. + :paramtype parameters: any + :keyword jit_access_policy: The managed application Jit access policy. + :paramtype jit_access_policy: + ~azure.mgmt.managedapplication.v2019_07_01.models.ApplicationJitAccessPolicy + """ + super(Application, self).__init__(location=location, tags=tags, managed_by=managed_by, sku=sku, **kwargs) + self.plan = plan + self.kind = kind + self.identity = identity + self.managed_resource_group_id = managed_resource_group_id + self.application_definition_id = application_definition_id + self.parameters = parameters + self.outputs = None + self.provisioning_state = None + self.billing_details = None + self.jit_access_policy = jit_access_policy + self.publisher_tenant_id = None + self.authorizations = None + self.management_mode = None + self.customer_support = None + self.support_urls = None + self.artifacts = None + self.created_by = None + self.updated_by = None + + +class ApplicationArtifact(msrest.serialization.Model): + """Managed application artifact. + + All required parameters must be populated in order to send to Azure. + + :ivar name: Required. The managed application artifact name. Known values are: "NotSpecified", + "ViewDefinition", "Authorizations", "CustomRoleDefinition". + :vartype name: str or ~azure.mgmt.managedapplication.v2019_07_01.models.ApplicationArtifactName + :ivar uri: Required. The managed application artifact blob uri. + :vartype uri: str + :ivar type: Required. The managed application artifact type. Known values are: "NotSpecified", + "Template", "Custom". + :vartype type: str or ~azure.mgmt.managedapplication.v2019_07_01.models.ApplicationArtifactType + """ + + _validation = { + 'name': {'required': True}, + 'uri': {'required': True}, + 'type': {'required': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'uri': {'key': 'uri', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + } + + def __init__( + self, + *, + name: Union[str, "_models.ApplicationArtifactName"], + uri: str, + type: Union[str, "_models.ApplicationArtifactType"], + **kwargs + ): + """ + :keyword name: Required. The managed application artifact name. Known values are: + "NotSpecified", "ViewDefinition", "Authorizations", "CustomRoleDefinition". + :paramtype name: str or + ~azure.mgmt.managedapplication.v2019_07_01.models.ApplicationArtifactName + :keyword uri: Required. The managed application artifact blob uri. + :paramtype uri: str + :keyword type: Required. The managed application artifact type. Known values are: + "NotSpecified", "Template", "Custom". + :paramtype type: str or + ~azure.mgmt.managedapplication.v2019_07_01.models.ApplicationArtifactType + """ + super(ApplicationArtifact, self).__init__(**kwargs) + self.name = name + self.uri = uri + self.type = type + + +class ApplicationAuthorization(msrest.serialization.Model): + """The managed application provider authorization. + + All required parameters must be populated in order to send to Azure. + + :ivar principal_id: Required. The provider's principal identifier. This is the identity that + the provider will use to call ARM to manage the managed application resources. + :vartype principal_id: str + :ivar role_definition_id: Required. The provider's role definition identifier. This role will + define all the permissions that the provider must have on the managed application's container + resource group. This role definition cannot have permission to delete the resource group. + :vartype role_definition_id: str + """ + + _validation = { + 'principal_id': {'required': True}, + 'role_definition_id': {'required': True}, + } + + _attribute_map = { + 'principal_id': {'key': 'principalId', 'type': 'str'}, + 'role_definition_id': {'key': 'roleDefinitionId', 'type': 'str'}, + } + + def __init__( + self, + *, + principal_id: str, + role_definition_id: str, + **kwargs + ): + """ + :keyword principal_id: Required. The provider's principal identifier. This is the identity that + the provider will use to call ARM to manage the managed application resources. + :paramtype principal_id: str + :keyword role_definition_id: Required. The provider's role definition identifier. This role + will define all the permissions that the provider must have on the managed application's + container resource group. This role definition cannot have permission to delete the resource + group. + :paramtype role_definition_id: str + """ + super(ApplicationAuthorization, self).__init__(**kwargs) + self.principal_id = principal_id + self.role_definition_id = role_definition_id + + +class ApplicationBillingDetailsDefinition(msrest.serialization.Model): + """Managed application billing details definition. + + :ivar resource_usage_id: The managed application resource usage Id. + :vartype resource_usage_id: str + """ + + _attribute_map = { + 'resource_usage_id': {'key': 'resourceUsageId', 'type': 'str'}, + } + + def __init__( + self, + *, + resource_usage_id: Optional[str] = None, + **kwargs + ): + """ + :keyword resource_usage_id: The managed application resource usage Id. + :paramtype resource_usage_id: str + """ + super(ApplicationBillingDetailsDefinition, self).__init__(**kwargs) + self.resource_usage_id = resource_usage_id + + +class ApplicationClientDetails(msrest.serialization.Model): + """The application client details to track the entity creating/updating the managed app resource. + + :ivar oid: The client Oid. + :vartype oid: str + :ivar puid: The client Puid. + :vartype puid: str + :ivar application_id: The client application Id. + :vartype application_id: str + """ + + _attribute_map = { + 'oid': {'key': 'oid', 'type': 'str'}, + 'puid': {'key': 'puid', 'type': 'str'}, + 'application_id': {'key': 'applicationId', 'type': 'str'}, + } + + def __init__( + self, + *, + oid: Optional[str] = None, + puid: Optional[str] = None, + application_id: Optional[str] = None, + **kwargs + ): + """ + :keyword oid: The client Oid. + :paramtype oid: str + :keyword puid: The client Puid. + :paramtype puid: str + :keyword application_id: The client application Id. + :paramtype application_id: str + """ + super(ApplicationClientDetails, self).__init__(**kwargs) + self.oid = oid + self.puid = puid + self.application_id = application_id + + +class ApplicationDefinition(GenericResource): + """Information about managed application definition. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar id: Resource ID. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar location: Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar managed_by: ID of the resource that manages this resource. + :vartype managed_by: str + :ivar sku: The SKU of the resource. + :vartype sku: ~azure.mgmt.managedapplication.v2019_07_01.models.Sku + :ivar lock_level: Required. The managed application lock level. Known values are: + "CanNotDelete", "ReadOnly", "None". + :vartype lock_level: str or + ~azure.mgmt.managedapplication.v2019_07_01.models.ApplicationLockLevel + :ivar display_name: The managed application definition display name. + :vartype display_name: str + :ivar is_enabled: A value indicating whether the package is enabled or not. + :vartype is_enabled: bool + :ivar authorizations: The managed application provider authorizations. + :vartype authorizations: + list[~azure.mgmt.managedapplication.v2019_07_01.models.ApplicationAuthorization] + :ivar artifacts: The collection of managed application artifacts. The portal will use the files + specified as artifacts to construct the user experience of creating a managed application from + a managed application definition. + :vartype artifacts: + list[~azure.mgmt.managedapplication.v2019_07_01.models.ApplicationDefinitionArtifact] + :ivar description: The managed application definition description. + :vartype description: str + :ivar package_file_uri: The managed application definition package file Uri. Use this element. + :vartype package_file_uri: str + :ivar storage_account_id: The storage account id for bring your own storage scenario. + :vartype storage_account_id: str + :ivar main_template: The inline main template json which has resources to be provisioned. It + can be a JObject or well-formed JSON string. + :vartype main_template: any + :ivar create_ui_definition: The createUiDefinition json for the backing template with + Microsoft.Solutions/applications resource. It can be a JObject or well-formed JSON string. + :vartype create_ui_definition: any + :ivar notification_policy: The managed application notification policy. + :vartype notification_policy: + ~azure.mgmt.managedapplication.v2019_07_01.models.ApplicationNotificationPolicy + :ivar locking_policy: The managed application locking policy. + :vartype locking_policy: + ~azure.mgmt.managedapplication.v2019_07_01.models.ApplicationPackageLockingPolicyDefinition + :ivar deployment_policy: The managed application deployment policy. + :vartype deployment_policy: + ~azure.mgmt.managedapplication.v2019_07_01.models.ApplicationDeploymentPolicy + :ivar management_policy: The managed application management policy that determines publisher's + access to the managed resource group. + :vartype management_policy: + ~azure.mgmt.managedapplication.v2019_07_01.models.ApplicationManagementPolicy + :ivar policies: The managed application provider policies. + :vartype policies: list[~azure.mgmt.managedapplication.v2019_07_01.models.ApplicationPolicy] + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'lock_level': {'required': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'location': {'key': 'location', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + 'managed_by': {'key': 'managedBy', 'type': 'str'}, + 'sku': {'key': 'sku', 'type': 'Sku'}, + 'lock_level': {'key': 'properties.lockLevel', 'type': 'str'}, + 'display_name': {'key': 'properties.displayName', 'type': 'str'}, + 'is_enabled': {'key': 'properties.isEnabled', 'type': 'bool'}, + 'authorizations': {'key': 'properties.authorizations', 'type': '[ApplicationAuthorization]'}, + 'artifacts': {'key': 'properties.artifacts', 'type': '[ApplicationDefinitionArtifact]'}, + 'description': {'key': 'properties.description', 'type': 'str'}, + 'package_file_uri': {'key': 'properties.packageFileUri', 'type': 'str'}, + 'storage_account_id': {'key': 'properties.storageAccountId', 'type': 'str'}, + 'main_template': {'key': 'properties.mainTemplate', 'type': 'object'}, + 'create_ui_definition': {'key': 'properties.createUiDefinition', 'type': 'object'}, + 'notification_policy': {'key': 'properties.notificationPolicy', 'type': 'ApplicationNotificationPolicy'}, + 'locking_policy': {'key': 'properties.lockingPolicy', 'type': 'ApplicationPackageLockingPolicyDefinition'}, + 'deployment_policy': {'key': 'properties.deploymentPolicy', 'type': 'ApplicationDeploymentPolicy'}, + 'management_policy': {'key': 'properties.managementPolicy', 'type': 'ApplicationManagementPolicy'}, + 'policies': {'key': 'properties.policies', 'type': '[ApplicationPolicy]'}, + } + + def __init__( + self, + *, + lock_level: Union[str, "_models.ApplicationLockLevel"], + location: Optional[str] = None, + tags: Optional[Dict[str, str]] = None, + managed_by: Optional[str] = None, + sku: Optional["_models.Sku"] = None, + display_name: Optional[str] = None, + is_enabled: Optional[bool] = None, + authorizations: Optional[List["_models.ApplicationAuthorization"]] = None, + artifacts: Optional[List["_models.ApplicationDefinitionArtifact"]] = None, + description: Optional[str] = None, + package_file_uri: Optional[str] = None, + storage_account_id: Optional[str] = None, + main_template: Optional[Any] = None, + create_ui_definition: Optional[Any] = None, + notification_policy: Optional["_models.ApplicationNotificationPolicy"] = None, + locking_policy: Optional["_models.ApplicationPackageLockingPolicyDefinition"] = None, + deployment_policy: Optional["_models.ApplicationDeploymentPolicy"] = None, + management_policy: Optional["_models.ApplicationManagementPolicy"] = None, + policies: Optional[List["_models.ApplicationPolicy"]] = None, + **kwargs + ): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword managed_by: ID of the resource that manages this resource. + :paramtype managed_by: str + :keyword sku: The SKU of the resource. + :paramtype sku: ~azure.mgmt.managedapplication.v2019_07_01.models.Sku + :keyword lock_level: Required. The managed application lock level. Known values are: + "CanNotDelete", "ReadOnly", "None". + :paramtype lock_level: str or + ~azure.mgmt.managedapplication.v2019_07_01.models.ApplicationLockLevel + :keyword display_name: The managed application definition display name. + :paramtype display_name: str + :keyword is_enabled: A value indicating whether the package is enabled or not. + :paramtype is_enabled: bool + :keyword authorizations: The managed application provider authorizations. + :paramtype authorizations: + list[~azure.mgmt.managedapplication.v2019_07_01.models.ApplicationAuthorization] + :keyword artifacts: The collection of managed application artifacts. The portal will use the + files specified as artifacts to construct the user experience of creating a managed application + from a managed application definition. + :paramtype artifacts: + list[~azure.mgmt.managedapplication.v2019_07_01.models.ApplicationDefinitionArtifact] + :keyword description: The managed application definition description. + :paramtype description: str + :keyword package_file_uri: The managed application definition package file Uri. Use this + element. + :paramtype package_file_uri: str + :keyword storage_account_id: The storage account id for bring your own storage scenario. + :paramtype storage_account_id: str + :keyword main_template: The inline main template json which has resources to be provisioned. It + can be a JObject or well-formed JSON string. + :paramtype main_template: any + :keyword create_ui_definition: The createUiDefinition json for the backing template with + Microsoft.Solutions/applications resource. It can be a JObject or well-formed JSON string. + :paramtype create_ui_definition: any + :keyword notification_policy: The managed application notification policy. + :paramtype notification_policy: + ~azure.mgmt.managedapplication.v2019_07_01.models.ApplicationNotificationPolicy + :keyword locking_policy: The managed application locking policy. + :paramtype locking_policy: + ~azure.mgmt.managedapplication.v2019_07_01.models.ApplicationPackageLockingPolicyDefinition + :keyword deployment_policy: The managed application deployment policy. + :paramtype deployment_policy: + ~azure.mgmt.managedapplication.v2019_07_01.models.ApplicationDeploymentPolicy + :keyword management_policy: The managed application management policy that determines + publisher's access to the managed resource group. + :paramtype management_policy: + ~azure.mgmt.managedapplication.v2019_07_01.models.ApplicationManagementPolicy + :keyword policies: The managed application provider policies. + :paramtype policies: list[~azure.mgmt.managedapplication.v2019_07_01.models.ApplicationPolicy] + """ + super(ApplicationDefinition, self).__init__(location=location, tags=tags, managed_by=managed_by, sku=sku, **kwargs) + self.lock_level = lock_level + self.display_name = display_name + self.is_enabled = is_enabled + self.authorizations = authorizations + self.artifacts = artifacts + self.description = description + self.package_file_uri = package_file_uri + self.storage_account_id = storage_account_id + self.main_template = main_template + self.create_ui_definition = create_ui_definition + self.notification_policy = notification_policy + self.locking_policy = locking_policy + self.deployment_policy = deployment_policy + self.management_policy = management_policy + self.policies = policies + + +class ApplicationDefinitionArtifact(msrest.serialization.Model): + """Application definition artifact. + + All required parameters must be populated in order to send to Azure. + + :ivar name: Required. The managed application definition artifact name. Known values are: + "NotSpecified", "ApplicationResourceTemplate", "CreateUiDefinition", "MainTemplateParameters". + :vartype name: str or + ~azure.mgmt.managedapplication.v2019_07_01.models.ApplicationDefinitionArtifactName + :ivar uri: Required. The managed application definition artifact blob uri. + :vartype uri: str + :ivar type: Required. The managed application definition artifact type. Known values are: + "NotSpecified", "Template", "Custom". + :vartype type: str or ~azure.mgmt.managedapplication.v2019_07_01.models.ApplicationArtifactType + """ + + _validation = { + 'name': {'required': True}, + 'uri': {'required': True}, + 'type': {'required': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'uri': {'key': 'uri', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + } + + def __init__( + self, + *, + name: Union[str, "_models.ApplicationDefinitionArtifactName"], + uri: str, + type: Union[str, "_models.ApplicationArtifactType"], + **kwargs + ): + """ + :keyword name: Required. The managed application definition artifact name. Known values are: + "NotSpecified", "ApplicationResourceTemplate", "CreateUiDefinition", "MainTemplateParameters". + :paramtype name: str or + ~azure.mgmt.managedapplication.v2019_07_01.models.ApplicationDefinitionArtifactName + :keyword uri: Required. The managed application definition artifact blob uri. + :paramtype uri: str + :keyword type: Required. The managed application definition artifact type. Known values are: + "NotSpecified", "Template", "Custom". + :paramtype type: str or + ~azure.mgmt.managedapplication.v2019_07_01.models.ApplicationArtifactType + """ + super(ApplicationDefinitionArtifact, self).__init__(**kwargs) + self.name = name + self.uri = uri + self.type = type + + +class ApplicationDefinitionListResult(msrest.serialization.Model): + """List of managed application definitions. + + :ivar value: The array of managed application definitions. + :vartype value: list[~azure.mgmt.managedapplication.v2019_07_01.models.ApplicationDefinition] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[ApplicationDefinition]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["_models.ApplicationDefinition"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + """ + :keyword value: The array of managed application definitions. + :paramtype value: list[~azure.mgmt.managedapplication.v2019_07_01.models.ApplicationDefinition] + :keyword next_link: The URL to use for getting the next set of results. + :paramtype next_link: str + """ + super(ApplicationDefinitionListResult, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class ApplicationDefinitionPatchable(msrest.serialization.Model): + """Information about an application definition request. + + :ivar tags: A set of tags. Application definition tags. + :vartype tags: dict[str, str] + """ + + _attribute_map = { + 'tags': {'key': 'tags', 'type': '{str}'}, + } + + def __init__( + self, + *, + tags: Optional[Dict[str, str]] = None, + **kwargs + ): + """ + :keyword tags: A set of tags. Application definition tags. + :paramtype tags: dict[str, str] + """ + super(ApplicationDefinitionPatchable, self).__init__(**kwargs) + self.tags = tags + + +class ApplicationDeploymentPolicy(msrest.serialization.Model): + """Managed application deployment policy. + + All required parameters must be populated in order to send to Azure. + + :ivar deployment_mode: Required. The managed application deployment mode. Known values are: + "NotSpecified", "Incremental", "Complete". + :vartype deployment_mode: str or + ~azure.mgmt.managedapplication.v2019_07_01.models.DeploymentMode + """ + + _validation = { + 'deployment_mode': {'required': True}, + } + + _attribute_map = { + 'deployment_mode': {'key': 'deploymentMode', 'type': 'str'}, + } + + def __init__( + self, + *, + deployment_mode: Union[str, "_models.DeploymentMode"], + **kwargs + ): + """ + :keyword deployment_mode: Required. The managed application deployment mode. Known values are: + "NotSpecified", "Incremental", "Complete". + :paramtype deployment_mode: str or + ~azure.mgmt.managedapplication.v2019_07_01.models.DeploymentMode + """ + super(ApplicationDeploymentPolicy, self).__init__(**kwargs) + self.deployment_mode = deployment_mode + + +class ApplicationJitAccessPolicy(msrest.serialization.Model): + """Managed application Jit access policy. + + All required parameters must be populated in order to send to Azure. + + :ivar jit_access_enabled: Required. Whether the JIT access is enabled. + :vartype jit_access_enabled: bool + :ivar jit_approval_mode: JIT approval mode. Known values are: "NotSpecified", "AutoApprove", + "ManualApprove". + :vartype jit_approval_mode: str or + ~azure.mgmt.managedapplication.v2019_07_01.models.JitApprovalMode + :ivar jit_approvers: The JIT approvers. + :vartype jit_approvers: + list[~azure.mgmt.managedapplication.v2019_07_01.models.JitApproverDefinition] + :ivar maximum_jit_access_duration: The maximum duration JIT access is granted. This is an + ISO8601 time period value. + :vartype maximum_jit_access_duration: str + """ + + _validation = { + 'jit_access_enabled': {'required': True}, + } + + _attribute_map = { + 'jit_access_enabled': {'key': 'jitAccessEnabled', 'type': 'bool'}, + 'jit_approval_mode': {'key': 'jitApprovalMode', 'type': 'str'}, + 'jit_approvers': {'key': 'jitApprovers', 'type': '[JitApproverDefinition]'}, + 'maximum_jit_access_duration': {'key': 'maximumJitAccessDuration', 'type': 'str'}, + } + + def __init__( + self, + *, + jit_access_enabled: bool, + jit_approval_mode: Optional[Union[str, "_models.JitApprovalMode"]] = None, + jit_approvers: Optional[List["_models.JitApproverDefinition"]] = None, + maximum_jit_access_duration: Optional[str] = None, + **kwargs + ): + """ + :keyword jit_access_enabled: Required. Whether the JIT access is enabled. + :paramtype jit_access_enabled: bool + :keyword jit_approval_mode: JIT approval mode. Known values are: "NotSpecified", "AutoApprove", + "ManualApprove". + :paramtype jit_approval_mode: str or + ~azure.mgmt.managedapplication.v2019_07_01.models.JitApprovalMode + :keyword jit_approvers: The JIT approvers. + :paramtype jit_approvers: + list[~azure.mgmt.managedapplication.v2019_07_01.models.JitApproverDefinition] + :keyword maximum_jit_access_duration: The maximum duration JIT access is granted. This is an + ISO8601 time period value. + :paramtype maximum_jit_access_duration: str + """ + super(ApplicationJitAccessPolicy, self).__init__(**kwargs) + self.jit_access_enabled = jit_access_enabled + self.jit_approval_mode = jit_approval_mode + self.jit_approvers = jit_approvers + self.maximum_jit_access_duration = maximum_jit_access_duration + + +class ApplicationListResult(msrest.serialization.Model): + """List of managed applications. + + :ivar value: The array of managed applications. + :vartype value: list[~azure.mgmt.managedapplication.v2019_07_01.models.Application] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Application]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["_models.Application"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + """ + :keyword value: The array of managed applications. + :paramtype value: list[~azure.mgmt.managedapplication.v2019_07_01.models.Application] + :keyword next_link: The URL to use for getting the next set of results. + :paramtype next_link: str + """ + super(ApplicationListResult, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class ApplicationManagementPolicy(msrest.serialization.Model): + """Managed application management policy. + + :ivar mode: The managed application management mode. Known values are: "NotSpecified", + "Unmanaged", "Managed". + :vartype mode: str or + ~azure.mgmt.managedapplication.v2019_07_01.models.ApplicationManagementMode + """ + + _attribute_map = { + 'mode': {'key': 'mode', 'type': 'str'}, + } + + def __init__( + self, + *, + mode: Optional[Union[str, "_models.ApplicationManagementMode"]] = None, + **kwargs + ): + """ + :keyword mode: The managed application management mode. Known values are: "NotSpecified", + "Unmanaged", "Managed". + :paramtype mode: str or + ~azure.mgmt.managedapplication.v2019_07_01.models.ApplicationManagementMode + """ + super(ApplicationManagementPolicy, self).__init__(**kwargs) + self.mode = mode + + +class ApplicationNotificationEndpoint(msrest.serialization.Model): + """Managed application notification endpoint. + + All required parameters must be populated in order to send to Azure. + + :ivar uri: Required. The managed application notification endpoint uri. + :vartype uri: str + """ + + _validation = { + 'uri': {'required': True}, + } + + _attribute_map = { + 'uri': {'key': 'uri', 'type': 'str'}, + } + + def __init__( + self, + *, + uri: str, + **kwargs + ): + """ + :keyword uri: Required. The managed application notification endpoint uri. + :paramtype uri: str + """ + super(ApplicationNotificationEndpoint, self).__init__(**kwargs) + self.uri = uri + + +class ApplicationNotificationPolicy(msrest.serialization.Model): + """Managed application notification policy. + + All required parameters must be populated in order to send to Azure. + + :ivar notification_endpoints: Required. The managed application notification endpoint. + :vartype notification_endpoints: + list[~azure.mgmt.managedapplication.v2019_07_01.models.ApplicationNotificationEndpoint] + """ + + _validation = { + 'notification_endpoints': {'required': True}, + } + + _attribute_map = { + 'notification_endpoints': {'key': 'notificationEndpoints', 'type': '[ApplicationNotificationEndpoint]'}, + } + + def __init__( + self, + *, + notification_endpoints: List["_models.ApplicationNotificationEndpoint"], + **kwargs + ): + """ + :keyword notification_endpoints: Required. The managed application notification endpoint. + :paramtype notification_endpoints: + list[~azure.mgmt.managedapplication.v2019_07_01.models.ApplicationNotificationEndpoint] + """ + super(ApplicationNotificationPolicy, self).__init__(**kwargs) + self.notification_endpoints = notification_endpoints + + +class ApplicationPackageContact(msrest.serialization.Model): + """The application package contact information. + + All required parameters must be populated in order to send to Azure. + + :ivar contact_name: The contact name. + :vartype contact_name: str + :ivar email: Required. The contact email. + :vartype email: str + :ivar phone: Required. The contact phone number. + :vartype phone: str + """ + + _validation = { + 'email': {'required': True}, + 'phone': {'required': True}, + } + + _attribute_map = { + 'contact_name': {'key': 'contactName', 'type': 'str'}, + 'email': {'key': 'email', 'type': 'str'}, + 'phone': {'key': 'phone', 'type': 'str'}, + } + + def __init__( + self, + *, + email: str, + phone: str, + contact_name: Optional[str] = None, + **kwargs + ): + """ + :keyword contact_name: The contact name. + :paramtype contact_name: str + :keyword email: Required. The contact email. + :paramtype email: str + :keyword phone: Required. The contact phone number. + :paramtype phone: str + """ + super(ApplicationPackageContact, self).__init__(**kwargs) + self.contact_name = contact_name + self.email = email + self.phone = phone + + +class ApplicationPackageLockingPolicyDefinition(msrest.serialization.Model): + """Managed application locking policy. + + :ivar allowed_actions: The deny assignment excluded actions. + :vartype allowed_actions: list[str] + :ivar allowed_data_actions: The deny assignment excluded data actions. + :vartype allowed_data_actions: list[str] + """ + + _attribute_map = { + 'allowed_actions': {'key': 'allowedActions', 'type': '[str]'}, + 'allowed_data_actions': {'key': 'allowedDataActions', 'type': '[str]'}, + } + + def __init__( + self, + *, + allowed_actions: Optional[List[str]] = None, + allowed_data_actions: Optional[List[str]] = None, + **kwargs + ): + """ + :keyword allowed_actions: The deny assignment excluded actions. + :paramtype allowed_actions: list[str] + :keyword allowed_data_actions: The deny assignment excluded data actions. + :paramtype allowed_data_actions: list[str] + """ + super(ApplicationPackageLockingPolicyDefinition, self).__init__(**kwargs) + self.allowed_actions = allowed_actions + self.allowed_data_actions = allowed_data_actions + + +class ApplicationPackageSupportUrls(msrest.serialization.Model): + """The appliance package support URLs. + + :ivar public_azure: The public azure support URL. + :vartype public_azure: str + :ivar government_cloud: The government cloud support URL. + :vartype government_cloud: str + """ + + _attribute_map = { + 'public_azure': {'key': 'publicAzure', 'type': 'str'}, + 'government_cloud': {'key': 'governmentCloud', 'type': 'str'}, + } + + def __init__( + self, + *, + public_azure: Optional[str] = None, + government_cloud: Optional[str] = None, + **kwargs + ): + """ + :keyword public_azure: The public azure support URL. + :paramtype public_azure: str + :keyword government_cloud: The government cloud support URL. + :paramtype government_cloud: str + """ + super(ApplicationPackageSupportUrls, self).__init__(**kwargs) + self.public_azure = public_azure + self.government_cloud = government_cloud + + +class ApplicationPatchable(GenericResource): + """Information about managed application. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Resource ID. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar location: Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar managed_by: ID of the resource that manages this resource. + :vartype managed_by: str + :ivar sku: The SKU of the resource. + :vartype sku: ~azure.mgmt.managedapplication.v2019_07_01.models.Sku + :ivar plan: The plan information. + :vartype plan: ~azure.mgmt.managedapplication.v2019_07_01.models.PlanPatchable + :ivar kind: The kind of the managed application. Allowed values are MarketPlace and + ServiceCatalog. + :vartype kind: str + :ivar identity: The identity of the resource. + :vartype identity: ~azure.mgmt.managedapplication.v2019_07_01.models.Identity + :ivar managed_resource_group_id: The managed resource group Id. + :vartype managed_resource_group_id: str + :ivar application_definition_id: The fully qualified path of managed application definition Id. + :vartype application_definition_id: str + :ivar parameters: Name and value pairs that define the managed application parameters. It can + be a JObject or a well formed JSON string. + :vartype parameters: any + :ivar outputs: Name and value pairs that define the managed application outputs. + :vartype outputs: any + :ivar provisioning_state: The managed application provisioning state. Known values are: + "NotSpecified", "Accepted", "Running", "Ready", "Creating", "Created", "Deleting", "Deleted", + "Canceled", "Failed", "Succeeded", "Updating". + :vartype provisioning_state: str or + ~azure.mgmt.managedapplication.v2019_07_01.models.ProvisioningState + :ivar billing_details: The managed application billing details. + :vartype billing_details: + ~azure.mgmt.managedapplication.v2019_07_01.models.ApplicationBillingDetailsDefinition + :ivar jit_access_policy: The managed application Jit access policy. + :vartype jit_access_policy: + ~azure.mgmt.managedapplication.v2019_07_01.models.ApplicationJitAccessPolicy + :ivar publisher_tenant_id: The publisher tenant Id. + :vartype publisher_tenant_id: str + :ivar authorizations: The read-only authorizations property that is retrieved from the + application package. + :vartype authorizations: + list[~azure.mgmt.managedapplication.v2019_07_01.models.ApplicationAuthorization] + :ivar management_mode: The managed application management mode. Known values are: + "NotSpecified", "Unmanaged", "Managed". + :vartype management_mode: str or + ~azure.mgmt.managedapplication.v2019_07_01.models.ApplicationManagementMode + :ivar customer_support: The read-only customer support property that is retrieved from the + application package. + :vartype customer_support: + ~azure.mgmt.managedapplication.v2019_07_01.models.ApplicationPackageContact + :ivar support_urls: The read-only support URLs property that is retrieved from the application + package. + :vartype support_urls: + ~azure.mgmt.managedapplication.v2019_07_01.models.ApplicationPackageSupportUrls + :ivar artifacts: The collection of managed application artifacts. + :vartype artifacts: list[~azure.mgmt.managedapplication.v2019_07_01.models.ApplicationArtifact] + :ivar created_by: The client entity that created the JIT request. + :vartype created_by: ~azure.mgmt.managedapplication.v2019_07_01.models.ApplicationClientDetails + :ivar updated_by: The client entity that last updated the JIT request. + :vartype updated_by: ~azure.mgmt.managedapplication.v2019_07_01.models.ApplicationClientDetails + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'kind': {'pattern': r'^[-\w\._,\(\)]+$'}, + 'outputs': {'readonly': True}, + 'provisioning_state': {'readonly': True}, + 'billing_details': {'readonly': True}, + 'publisher_tenant_id': {'readonly': True}, + 'authorizations': {'readonly': True}, + 'management_mode': {'readonly': True}, + 'customer_support': {'readonly': True}, + 'support_urls': {'readonly': True}, + 'artifacts': {'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'}, + 'location': {'key': 'location', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + 'managed_by': {'key': 'managedBy', 'type': 'str'}, + 'sku': {'key': 'sku', 'type': 'Sku'}, + 'plan': {'key': 'plan', 'type': 'PlanPatchable'}, + 'kind': {'key': 'kind', 'type': 'str'}, + 'identity': {'key': 'identity', 'type': 'Identity'}, + 'managed_resource_group_id': {'key': 'properties.managedResourceGroupId', 'type': 'str'}, + 'application_definition_id': {'key': 'properties.applicationDefinitionId', 'type': 'str'}, + 'parameters': {'key': 'properties.parameters', 'type': 'object'}, + 'outputs': {'key': 'properties.outputs', 'type': 'object'}, + 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + 'billing_details': {'key': 'properties.billingDetails', 'type': 'ApplicationBillingDetailsDefinition'}, + 'jit_access_policy': {'key': 'properties.jitAccessPolicy', 'type': 'ApplicationJitAccessPolicy'}, + 'publisher_tenant_id': {'key': 'properties.publisherTenantId', 'type': 'str'}, + 'authorizations': {'key': 'properties.authorizations', 'type': '[ApplicationAuthorization]'}, + 'management_mode': {'key': 'properties.managementMode', 'type': 'str'}, + 'customer_support': {'key': 'properties.customerSupport', 'type': 'ApplicationPackageContact'}, + 'support_urls': {'key': 'properties.supportUrls', 'type': 'ApplicationPackageSupportUrls'}, + 'artifacts': {'key': 'properties.artifacts', 'type': '[ApplicationArtifact]'}, + 'created_by': {'key': 'properties.createdBy', 'type': 'ApplicationClientDetails'}, + 'updated_by': {'key': 'properties.updatedBy', 'type': 'ApplicationClientDetails'}, + } + + def __init__( + self, + *, + location: Optional[str] = None, + tags: Optional[Dict[str, str]] = None, + managed_by: Optional[str] = None, + sku: Optional["_models.Sku"] = None, + plan: Optional["_models.PlanPatchable"] = None, + kind: Optional[str] = None, + identity: Optional["_models.Identity"] = None, + managed_resource_group_id: Optional[str] = None, + application_definition_id: Optional[str] = None, + parameters: Optional[Any] = None, + jit_access_policy: Optional["_models.ApplicationJitAccessPolicy"] = None, + **kwargs + ): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword managed_by: ID of the resource that manages this resource. + :paramtype managed_by: str + :keyword sku: The SKU of the resource. + :paramtype sku: ~azure.mgmt.managedapplication.v2019_07_01.models.Sku + :keyword plan: The plan information. + :paramtype plan: ~azure.mgmt.managedapplication.v2019_07_01.models.PlanPatchable + :keyword kind: The kind of the managed application. Allowed values are MarketPlace and + ServiceCatalog. + :paramtype kind: str + :keyword identity: The identity of the resource. + :paramtype identity: ~azure.mgmt.managedapplication.v2019_07_01.models.Identity + :keyword managed_resource_group_id: The managed resource group Id. + :paramtype managed_resource_group_id: str + :keyword application_definition_id: The fully qualified path of managed application definition + Id. + :paramtype application_definition_id: str + :keyword parameters: Name and value pairs that define the managed application parameters. It + can be a JObject or a well formed JSON string. + :paramtype parameters: any + :keyword jit_access_policy: The managed application Jit access policy. + :paramtype jit_access_policy: + ~azure.mgmt.managedapplication.v2019_07_01.models.ApplicationJitAccessPolicy + """ + super(ApplicationPatchable, self).__init__(location=location, tags=tags, managed_by=managed_by, sku=sku, **kwargs) + self.plan = plan + self.kind = kind + self.identity = identity + self.managed_resource_group_id = managed_resource_group_id + self.application_definition_id = application_definition_id + self.parameters = parameters + self.outputs = None + self.provisioning_state = None + self.billing_details = None + self.jit_access_policy = jit_access_policy + self.publisher_tenant_id = None + self.authorizations = None + self.management_mode = None + self.customer_support = None + self.support_urls = None + self.artifacts = None + self.created_by = None + self.updated_by = None + + +class ApplicationPolicy(msrest.serialization.Model): + """Managed application policy. + + :ivar name: The policy name. + :vartype name: str + :ivar policy_definition_id: The policy definition Id. + :vartype policy_definition_id: str + :ivar parameters: The policy parameters. + :vartype parameters: str + """ + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'policy_definition_id': {'key': 'policyDefinitionId', 'type': 'str'}, + 'parameters': {'key': 'parameters', 'type': 'str'}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + policy_definition_id: Optional[str] = None, + parameters: Optional[str] = None, + **kwargs + ): + """ + :keyword name: The policy name. + :paramtype name: str + :keyword policy_definition_id: The policy definition Id. + :paramtype policy_definition_id: str + :keyword parameters: The policy parameters. + :paramtype parameters: str + """ + super(ApplicationPolicy, self).__init__(**kwargs) + self.name = name + self.policy_definition_id = policy_definition_id + self.parameters = parameters + + +class ApplicationPropertiesPatchable(msrest.serialization.Model): + """The managed application properties. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar managed_resource_group_id: The managed resource group Id. + :vartype managed_resource_group_id: str + :ivar application_definition_id: The fully qualified path of managed application definition Id. + :vartype application_definition_id: str + :ivar parameters: Name and value pairs that define the managed application parameters. It can + be a JObject or a well formed JSON string. + :vartype parameters: any + :ivar outputs: Name and value pairs that define the managed application outputs. + :vartype outputs: any + :ivar provisioning_state: The managed application provisioning state. Known values are: + "NotSpecified", "Accepted", "Running", "Ready", "Creating", "Created", "Deleting", "Deleted", + "Canceled", "Failed", "Succeeded", "Updating". + :vartype provisioning_state: str or + ~azure.mgmt.managedapplication.v2019_07_01.models.ProvisioningState + """ + + _validation = { + 'outputs': {'readonly': True}, + 'provisioning_state': {'readonly': True}, + } + + _attribute_map = { + 'managed_resource_group_id': {'key': 'managedResourceGroupId', 'type': 'str'}, + 'application_definition_id': {'key': 'applicationDefinitionId', 'type': 'str'}, + 'parameters': {'key': 'parameters', 'type': 'object'}, + 'outputs': {'key': 'outputs', 'type': 'object'}, + 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, + } + + def __init__( + self, + *, + managed_resource_group_id: Optional[str] = None, + application_definition_id: Optional[str] = None, + parameters: Optional[Any] = None, + **kwargs + ): + """ + :keyword managed_resource_group_id: The managed resource group Id. + :paramtype managed_resource_group_id: str + :keyword application_definition_id: The fully qualified path of managed application definition + Id. + :paramtype application_definition_id: str + :keyword parameters: Name and value pairs that define the managed application parameters. It + can be a JObject or a well formed JSON string. + :paramtype parameters: any + """ + super(ApplicationPropertiesPatchable, self).__init__(**kwargs) + self.managed_resource_group_id = managed_resource_group_id + self.application_definition_id = application_definition_id + self.parameters = parameters + self.outputs = None + self.provisioning_state = None + + +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.managedapplication.v2019_07_01.models.ErrorDetail] + :ivar additional_info: The error additional info. + :vartype additional_info: + list[~azure.mgmt.managedapplication.v2019_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.). + + :ivar error: The error object. + :vartype error: ~azure.mgmt.managedapplication.v2019_07_01.models.ErrorDetail + """ + + _attribute_map = { + 'error': {'key': 'error', 'type': 'ErrorDetail'}, + } + + def __init__( + self, + *, + error: Optional["_models.ErrorDetail"] = None, + **kwargs + ): + """ + :keyword error: The error object. + :paramtype error: ~azure.mgmt.managedapplication.v2019_07_01.models.ErrorDetail + """ + super(ErrorResponse, self).__init__(**kwargs) + self.error = error + + +class Identity(msrest.serialization.Model): + """Identity for the resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar principal_id: The principal ID of resource identity. + :vartype principal_id: str + :ivar tenant_id: The tenant ID of resource. + :vartype tenant_id: str + :ivar type: The identity type. Known values are: "SystemAssigned", "UserAssigned", + "SystemAssigned, UserAssigned", "None". + :vartype type: str or ~azure.mgmt.managedapplication.v2019_07_01.models.ResourceIdentityType + :ivar user_assigned_identities: The list of user identities associated with the resource. The + user identity dictionary key references will be resource ids in the form: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'. + :vartype user_assigned_identities: dict[str, + ~azure.mgmt.managedapplication.v2019_07_01.models.UserAssignedResourceIdentity] + """ + + _validation = { + 'principal_id': {'readonly': True}, + 'tenant_id': {'readonly': True}, + } + + _attribute_map = { + 'principal_id': {'key': 'principalId', 'type': 'str'}, + 'tenant_id': {'key': 'tenantId', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'user_assigned_identities': {'key': 'userAssignedIdentities', 'type': '{UserAssignedResourceIdentity}'}, + } + + def __init__( + self, + *, + type: Optional[Union[str, "_models.ResourceIdentityType"]] = None, + user_assigned_identities: Optional[Dict[str, "_models.UserAssignedResourceIdentity"]] = None, + **kwargs + ): + """ + :keyword type: The identity type. Known values are: "SystemAssigned", "UserAssigned", + "SystemAssigned, UserAssigned", "None". + :paramtype type: str or ~azure.mgmt.managedapplication.v2019_07_01.models.ResourceIdentityType + :keyword user_assigned_identities: The list of user identities associated with the resource. + The user identity dictionary key references will be resource ids in the form: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'. + :paramtype user_assigned_identities: dict[str, + ~azure.mgmt.managedapplication.v2019_07_01.models.UserAssignedResourceIdentity] + """ + super(Identity, self).__init__(**kwargs) + self.principal_id = None + self.tenant_id = None + self.type = type + self.user_assigned_identities = user_assigned_identities + + +class JitApproverDefinition(msrest.serialization.Model): + """JIT approver definition. + + All required parameters must be populated in order to send to Azure. + + :ivar id: Required. The approver service principal Id. + :vartype id: str + :ivar type: The approver type. Known values are: "user", "group". + :vartype type: str or ~azure.mgmt.managedapplication.v2019_07_01.models.JitApproverType + :ivar display_name: The approver display name. + :vartype display_name: str + """ + + _validation = { + 'id': {'required': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'display_name': {'key': 'displayName', 'type': 'str'}, + } + + def __init__( + self, + *, + id: str, + type: Optional[Union[str, "_models.JitApproverType"]] = None, + display_name: Optional[str] = None, + **kwargs + ): + """ + :keyword id: Required. The approver service principal Id. + :paramtype id: str + :keyword type: The approver type. Known values are: "user", "group". + :paramtype type: str or ~azure.mgmt.managedapplication.v2019_07_01.models.JitApproverType + :keyword display_name: The approver display name. + :paramtype display_name: str + """ + super(JitApproverDefinition, self).__init__(**kwargs) + self.id = id + self.type = type + self.display_name = display_name + + +class JitAuthorizationPolicies(msrest.serialization.Model): + """The JIT authorization policies. + + All required parameters must be populated in order to send to Azure. + + :ivar principal_id: Required. The the principal id that will be granted JIT access. + :vartype principal_id: str + :ivar role_definition_id: Required. The role definition id that will be granted to the + Principal. + :vartype role_definition_id: str + """ + + _validation = { + 'principal_id': {'required': True}, + 'role_definition_id': {'required': True}, + } + + _attribute_map = { + 'principal_id': {'key': 'principalId', 'type': 'str'}, + 'role_definition_id': {'key': 'roleDefinitionId', 'type': 'str'}, + } + + def __init__( + self, + *, + principal_id: str, + role_definition_id: str, + **kwargs + ): + """ + :keyword principal_id: Required. The the principal id that will be granted JIT access. + :paramtype principal_id: str + :keyword role_definition_id: Required. The role definition id that will be granted to the + Principal. + :paramtype role_definition_id: str + """ + super(JitAuthorizationPolicies, self).__init__(**kwargs) + self.principal_id = principal_id + self.role_definition_id = role_definition_id + + +class JitRequestDefinition(Resource): + """Information about JIT request definition. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Resource ID. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar location: Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar application_resource_id: The parent application id. + :vartype application_resource_id: str + :ivar publisher_tenant_id: The publisher tenant id. + :vartype publisher_tenant_id: str + :ivar jit_authorization_policies: The JIT authorization policies. + :vartype jit_authorization_policies: + list[~azure.mgmt.managedapplication.v2019_07_01.models.JitAuthorizationPolicies] + :ivar jit_scheduling_policy: The JIT request properties. + :vartype jit_scheduling_policy: + ~azure.mgmt.managedapplication.v2019_07_01.models.JitSchedulingPolicy + :ivar provisioning_state: The JIT request provisioning state. Known values are: "NotSpecified", + "Accepted", "Running", "Ready", "Creating", "Created", "Deleting", "Deleted", "Canceled", + "Failed", "Succeeded", "Updating". + :vartype provisioning_state: str or + ~azure.mgmt.managedapplication.v2019_07_01.models.ProvisioningState + :ivar jit_request_state: The JIT request state. Known values are: "NotSpecified", "Pending", + "Approved", "Denied", "Failed", "Canceled", "Expired", "Timeout". + :vartype jit_request_state: str or + ~azure.mgmt.managedapplication.v2019_07_01.models.JitRequestState + :ivar created_by: The client entity that created the JIT request. + :vartype created_by: ~azure.mgmt.managedapplication.v2019_07_01.models.ApplicationClientDetails + :ivar updated_by: The client entity that last updated the JIT request. + :vartype updated_by: ~azure.mgmt.managedapplication.v2019_07_01.models.ApplicationClientDetails + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'publisher_tenant_id': {'readonly': True}, + 'provisioning_state': {'readonly': True}, + 'jit_request_state': {'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'}, + 'location': {'key': 'location', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + 'application_resource_id': {'key': 'properties.applicationResourceId', 'type': 'str'}, + 'publisher_tenant_id': {'key': 'properties.publisherTenantId', 'type': 'str'}, + 'jit_authorization_policies': {'key': 'properties.jitAuthorizationPolicies', 'type': '[JitAuthorizationPolicies]'}, + 'jit_scheduling_policy': {'key': 'properties.jitSchedulingPolicy', 'type': 'JitSchedulingPolicy'}, + 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + 'jit_request_state': {'key': 'properties.jitRequestState', 'type': 'str'}, + 'created_by': {'key': 'properties.createdBy', 'type': 'ApplicationClientDetails'}, + 'updated_by': {'key': 'properties.updatedBy', 'type': 'ApplicationClientDetails'}, + } + + def __init__( + self, + *, + location: Optional[str] = None, + tags: Optional[Dict[str, str]] = None, + application_resource_id: Optional[str] = None, + jit_authorization_policies: Optional[List["_models.JitAuthorizationPolicies"]] = None, + jit_scheduling_policy: Optional["_models.JitSchedulingPolicy"] = None, + **kwargs + ): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword application_resource_id: The parent application id. + :paramtype application_resource_id: str + :keyword jit_authorization_policies: The JIT authorization policies. + :paramtype jit_authorization_policies: + list[~azure.mgmt.managedapplication.v2019_07_01.models.JitAuthorizationPolicies] + :keyword jit_scheduling_policy: The JIT request properties. + :paramtype jit_scheduling_policy: + ~azure.mgmt.managedapplication.v2019_07_01.models.JitSchedulingPolicy + """ + super(JitRequestDefinition, self).__init__(location=location, tags=tags, **kwargs) + self.application_resource_id = application_resource_id + self.publisher_tenant_id = None + self.jit_authorization_policies = jit_authorization_policies + self.jit_scheduling_policy = jit_scheduling_policy + self.provisioning_state = None + self.jit_request_state = None + self.created_by = None + self.updated_by = None + + +class JitRequestDefinitionListResult(msrest.serialization.Model): + """List of JIT requests. + + :ivar value: The array of Jit request definition. + :vartype value: list[~azure.mgmt.managedapplication.v2019_07_01.models.JitRequestDefinition] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[JitRequestDefinition]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["_models.JitRequestDefinition"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + """ + :keyword value: The array of Jit request definition. + :paramtype value: list[~azure.mgmt.managedapplication.v2019_07_01.models.JitRequestDefinition] + :keyword next_link: The URL to use for getting the next set of results. + :paramtype next_link: str + """ + super(JitRequestDefinitionListResult, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class JitRequestMetadata(msrest.serialization.Model): + """The JIT request metadata. + + :ivar origin_request_id: The origin request id. + :vartype origin_request_id: str + :ivar requestor_id: The requestor id. + :vartype requestor_id: str + :ivar tenant_display_name: The publisher's tenant name. + :vartype tenant_display_name: str + :ivar subject_display_name: The subject display name. + :vartype subject_display_name: str + """ + + _attribute_map = { + 'origin_request_id': {'key': 'originRequestId', 'type': 'str'}, + 'requestor_id': {'key': 'requestorId', 'type': 'str'}, + 'tenant_display_name': {'key': 'tenantDisplayName', 'type': 'str'}, + 'subject_display_name': {'key': 'subjectDisplayName', 'type': 'str'}, + } + + def __init__( + self, + *, + origin_request_id: Optional[str] = None, + requestor_id: Optional[str] = None, + tenant_display_name: Optional[str] = None, + subject_display_name: Optional[str] = None, + **kwargs + ): + """ + :keyword origin_request_id: The origin request id. + :paramtype origin_request_id: str + :keyword requestor_id: The requestor id. + :paramtype requestor_id: str + :keyword tenant_display_name: The publisher's tenant name. + :paramtype tenant_display_name: str + :keyword subject_display_name: The subject display name. + :paramtype subject_display_name: str + """ + super(JitRequestMetadata, self).__init__(**kwargs) + self.origin_request_id = origin_request_id + self.requestor_id = requestor_id + self.tenant_display_name = tenant_display_name + self.subject_display_name = subject_display_name + + +class JitRequestPatchable(msrest.serialization.Model): + """Information about JIT request. + + :ivar tags: A set of tags. Jit request tags. + :vartype tags: dict[str, str] + """ + + _attribute_map = { + 'tags': {'key': 'tags', 'type': '{str}'}, + } + + def __init__( + self, + *, + tags: Optional[Dict[str, str]] = None, + **kwargs + ): + """ + :keyword tags: A set of tags. Jit request tags. + :paramtype tags: dict[str, str] + """ + super(JitRequestPatchable, self).__init__(**kwargs) + self.tags = tags + + +class JitSchedulingPolicy(msrest.serialization.Model): + """The JIT scheduling policies. + + All required parameters must be populated in order to send to Azure. + + :ivar type: Required. The type of JIT schedule. Known values are: "NotSpecified", "Once", + "Recurring". + :vartype type: str or ~azure.mgmt.managedapplication.v2019_07_01.models.JitSchedulingType + :ivar duration: Required. The required duration of the JIT request. + :vartype duration: ~datetime.timedelta + :ivar start_time: Required. The start time of the request. + :vartype start_time: ~datetime.datetime + """ + + _validation = { + 'type': {'required': True}, + 'duration': {'required': True}, + 'start_time': {'required': True}, + } + + _attribute_map = { + 'type': {'key': 'type', 'type': 'str'}, + 'duration': {'key': 'duration', 'type': 'duration'}, + 'start_time': {'key': 'startTime', 'type': 'iso-8601'}, + } + + def __init__( + self, + *, + type: Union[str, "_models.JitSchedulingType"], + duration: datetime.timedelta, + start_time: datetime.datetime, + **kwargs + ): + """ + :keyword type: Required. The type of JIT schedule. Known values are: "NotSpecified", "Once", + "Recurring". + :paramtype type: str or ~azure.mgmt.managedapplication.v2019_07_01.models.JitSchedulingType + :keyword duration: Required. The required duration of the JIT request. + :paramtype duration: ~datetime.timedelta + :keyword start_time: Required. The start time of the request. + :paramtype start_time: ~datetime.datetime + """ + super(JitSchedulingPolicy, self).__init__(**kwargs) + self.type = type + self.duration = duration + self.start_time = start_time + + +class ListTokenRequest(msrest.serialization.Model): + """List token request body. + + :ivar authorization_audience: The authorization audience. + :vartype authorization_audience: str + :ivar user_assigned_identities: The user assigned identities. + :vartype user_assigned_identities: list[str] + """ + + _attribute_map = { + 'authorization_audience': {'key': 'authorizationAudience', 'type': 'str'}, + 'user_assigned_identities': {'key': 'userAssignedIdentities', 'type': '[str]'}, + } + + def __init__( + self, + *, + authorization_audience: Optional[str] = None, + user_assigned_identities: Optional[List[str]] = None, + **kwargs + ): + """ + :keyword authorization_audience: The authorization audience. + :paramtype authorization_audience: str + :keyword user_assigned_identities: The user assigned identities. + :paramtype user_assigned_identities: list[str] + """ + super(ListTokenRequest, self).__init__(**kwargs) + self.authorization_audience = authorization_audience + self.user_assigned_identities = user_assigned_identities + + +class ManagedIdentityToken(msrest.serialization.Model): + """The managed identity token for the managed app resource. + + :ivar access_token: The requested access token. + :vartype access_token: str + :ivar expires_in: The number of seconds the access token will be valid. + :vartype expires_in: str + :ivar expires_on: The timespan when the access token expires. This is represented as the number + of seconds from epoch. + :vartype expires_on: str + :ivar not_before: The timespan when the access token takes effect. This is represented as the + number of seconds from epoch. + :vartype not_before: str + :ivar authorization_audience: The aud (audience) the access token was request for. This is the + same as what was provided in the listTokens request. + :vartype authorization_audience: str + :ivar resource_id: The Azure resource ID for the issued token. This is either the managed + application ID or the user-assigned identity ID. + :vartype resource_id: str + :ivar token_type: The type of the token. + :vartype token_type: str + """ + + _attribute_map = { + 'access_token': {'key': 'accessToken', 'type': 'str'}, + 'expires_in': {'key': 'expiresIn', 'type': 'str'}, + 'expires_on': {'key': 'expiresOn', 'type': 'str'}, + 'not_before': {'key': 'notBefore', 'type': 'str'}, + 'authorization_audience': {'key': 'authorizationAudience', 'type': 'str'}, + 'resource_id': {'key': 'resourceId', 'type': 'str'}, + 'token_type': {'key': 'tokenType', 'type': 'str'}, + } + + def __init__( + self, + *, + access_token: Optional[str] = None, + expires_in: Optional[str] = None, + expires_on: Optional[str] = None, + not_before: Optional[str] = None, + authorization_audience: Optional[str] = None, + resource_id: Optional[str] = None, + token_type: Optional[str] = None, + **kwargs + ): + """ + :keyword access_token: The requested access token. + :paramtype access_token: str + :keyword expires_in: The number of seconds the access token will be valid. + :paramtype expires_in: str + :keyword expires_on: The timespan when the access token expires. This is represented as the + number of seconds from epoch. + :paramtype expires_on: str + :keyword not_before: The timespan when the access token takes effect. This is represented as + the number of seconds from epoch. + :paramtype not_before: str + :keyword authorization_audience: The aud (audience) the access token was request for. This is + the same as what was provided in the listTokens request. + :paramtype authorization_audience: str + :keyword resource_id: The Azure resource ID for the issued token. This is either the managed + application ID or the user-assigned identity ID. + :paramtype resource_id: str + :keyword token_type: The type of the token. + :paramtype token_type: str + """ + super(ManagedIdentityToken, self).__init__(**kwargs) + self.access_token = access_token + self.expires_in = expires_in + self.expires_on = expires_on + self.not_before = not_before + self.authorization_audience = authorization_audience + self.resource_id = resource_id + self.token_type = token_type + + +class ManagedIdentityTokenResult(msrest.serialization.Model): + """The array of managed identity tokens. + + :ivar value: The array of managed identity tokens. + :vartype value: list[~azure.mgmt.managedapplication.v2019_07_01.models.ManagedIdentityToken] + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[ManagedIdentityToken]'}, + } + + def __init__( + self, + *, + value: Optional[List["_models.ManagedIdentityToken"]] = None, + **kwargs + ): + """ + :keyword value: The array of managed identity tokens. + :paramtype value: list[~azure.mgmt.managedapplication.v2019_07_01.models.ManagedIdentityToken] + """ + super(ManagedIdentityTokenResult, self).__init__(**kwargs) + self.value = value + + +class Operation(msrest.serialization.Model): + """Details of a REST API operation, returned from the Resource Provider Operations API. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name: The name of the operation, as per Resource-Based Access Control (RBAC). Examples: + "Microsoft.Compute/virtualMachines/write", "Microsoft.Compute/virtualMachines/capture/action". + :vartype name: str + :ivar is_data_action: Whether the operation applies to data-plane. This is "true" for + data-plane operations and "false" for ARM/control-plane operations. + :vartype is_data_action: bool + :ivar display: Localized display information for this particular operation. + :vartype display: ~azure.mgmt.managedapplication.v2019_07_01.models.OperationDisplay + :ivar origin: The intended executor of the operation; as in Resource Based Access Control + (RBAC) and audit logs UX. Default value is "user,system". Known values are: "user", "system", + "user,system". + :vartype origin: str or ~azure.mgmt.managedapplication.v2019_07_01.models.Origin + :ivar action_type: Enum. Indicates the action type. "Internal" refers to actions that are for + internal only APIs. Known values are: "Internal". + :vartype action_type: str or ~azure.mgmt.managedapplication.v2019_07_01.models.ActionType + """ + + _validation = { + 'name': {'readonly': True}, + 'is_data_action': {'readonly': True}, + 'origin': {'readonly': True}, + 'action_type': {'readonly': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'is_data_action': {'key': 'isDataAction', 'type': 'bool'}, + 'display': {'key': 'display', 'type': 'OperationDisplay'}, + 'origin': {'key': 'origin', 'type': 'str'}, + 'action_type': {'key': 'actionType', 'type': 'str'}, + } + + def __init__( + self, + *, + display: Optional["_models.OperationDisplay"] = None, + **kwargs + ): + """ + :keyword display: Localized display information for this particular operation. + :paramtype display: ~azure.mgmt.managedapplication.v2019_07_01.models.OperationDisplay + """ + super(Operation, self).__init__(**kwargs) + self.name = None + self.is_data_action = None + self.display = display + self.origin = None + self.action_type = None + + +class OperationAutoGenerated(msrest.serialization.Model): + """Microsoft.Solutions operation. + + :ivar name: Operation name: {provider}/{resource}/{operation}. + :vartype name: str + :ivar display: The object that represents the operation. + :vartype display: + ~azure.mgmt.managedapplication.v2019_07_01.models.OperationDisplayAutoGenerated + """ + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'display': {'key': 'display', 'type': 'OperationDisplayAutoGenerated'}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + display: Optional["_models.OperationDisplayAutoGenerated"] = None, + **kwargs + ): + """ + :keyword name: Operation name: {provider}/{resource}/{operation}. + :paramtype name: str + :keyword display: The object that represents the operation. + :paramtype display: + ~azure.mgmt.managedapplication.v2019_07_01.models.OperationDisplayAutoGenerated + """ + super(OperationAutoGenerated, self).__init__(**kwargs) + self.name = name + self.display = display + + +class OperationDisplay(msrest.serialization.Model): + """Localized display information for this particular operation. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar provider: The localized friendly form of the resource provider name, e.g. "Microsoft + Monitoring Insights" or "Microsoft Compute". + :vartype provider: str + :ivar resource: The localized friendly name of the resource type related to this operation. + E.g. "Virtual Machines" or "Job Schedule Collections". + :vartype resource: str + :ivar operation: The concise, localized friendly name for the operation; suitable for + dropdowns. E.g. "Create or Update Virtual Machine", "Restart Virtual Machine". + :vartype operation: str + :ivar description: The short, localized friendly description of the operation; suitable for + tool tips and detailed views. + :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 OperationDisplayAutoGenerated(msrest.serialization.Model): + """The object that represents the operation. + + :ivar provider: Service provider: Microsoft.Solutions. + :vartype provider: str + :ivar resource: Resource on which the operation is performed: Application, JitRequest, etc. + :vartype resource: str + :ivar operation: Operation type: Read, write, delete, etc. + :vartype operation: str + """ + + _attribute_map = { + 'provider': {'key': 'provider', 'type': 'str'}, + 'resource': {'key': 'resource', 'type': 'str'}, + 'operation': {'key': 'operation', 'type': 'str'}, + } + + def __init__( + self, + *, + provider: Optional[str] = None, + resource: Optional[str] = None, + operation: Optional[str] = None, + **kwargs + ): + """ + :keyword provider: Service provider: Microsoft.Solutions. + :paramtype provider: str + :keyword resource: Resource on which the operation is performed: Application, JitRequest, etc. + :paramtype resource: str + :keyword operation: Operation type: Read, write, delete, etc. + :paramtype operation: str + """ + super(OperationDisplayAutoGenerated, self).__init__(**kwargs) + self.provider = provider + self.resource = resource + self.operation = operation + + +class OperationListResult(msrest.serialization.Model): + """A list of REST API operations supported by an Azure Resource Provider. It contains an URL link to get the next set of results. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: List of operations supported by the resource provider. + :vartype value: list[~azure.mgmt.managedapplication.v2019_07_01.models.Operation] + :ivar next_link: URL to get the next set of operation list results (if there are any). + :vartype next_link: str + """ + + _validation = { + 'value': {'readonly': True}, + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Operation]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(OperationListResult, self).__init__(**kwargs) + self.value = None + self.next_link = None + + +class Plan(msrest.serialization.Model): + """Plan for the managed application. + + All required parameters must be populated in order to send to Azure. + + :ivar name: Required. The plan name. + :vartype name: str + :ivar publisher: Required. The publisher ID. + :vartype publisher: str + :ivar product: Required. The product code. + :vartype product: str + :ivar promotion_code: The promotion code. + :vartype promotion_code: str + :ivar version: Required. The plan's version. + :vartype version: str + """ + + _validation = { + 'name': {'required': True}, + 'publisher': {'required': True}, + 'product': {'required': True}, + 'version': {'required': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'publisher': {'key': 'publisher', 'type': 'str'}, + 'product': {'key': 'product', 'type': 'str'}, + 'promotion_code': {'key': 'promotionCode', 'type': 'str'}, + 'version': {'key': 'version', 'type': 'str'}, + } + + def __init__( + self, + *, + name: str, + publisher: str, + product: str, + version: str, + promotion_code: Optional[str] = None, + **kwargs + ): + """ + :keyword name: Required. The plan name. + :paramtype name: str + :keyword publisher: Required. The publisher ID. + :paramtype publisher: str + :keyword product: Required. The product code. + :paramtype product: str + :keyword promotion_code: The promotion code. + :paramtype promotion_code: str + :keyword version: Required. The plan's version. + :paramtype version: str + """ + super(Plan, self).__init__(**kwargs) + self.name = name + self.publisher = publisher + self.product = product + self.promotion_code = promotion_code + self.version = version + + +class PlanPatchable(msrest.serialization.Model): + """Plan for the managed application. + + :ivar name: The plan name. + :vartype name: str + :ivar publisher: The publisher ID. + :vartype publisher: str + :ivar product: The product code. + :vartype product: str + :ivar promotion_code: The promotion code. + :vartype promotion_code: str + :ivar version: The plan's version. + :vartype version: str + """ + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'publisher': {'key': 'publisher', 'type': 'str'}, + 'product': {'key': 'product', 'type': 'str'}, + 'promotion_code': {'key': 'promotionCode', 'type': 'str'}, + 'version': {'key': 'version', 'type': 'str'}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + publisher: Optional[str] = None, + product: Optional[str] = None, + promotion_code: Optional[str] = None, + version: Optional[str] = None, + **kwargs + ): + """ + :keyword name: The plan name. + :paramtype name: str + :keyword publisher: The publisher ID. + :paramtype publisher: str + :keyword product: The product code. + :paramtype product: str + :keyword promotion_code: The promotion code. + :paramtype promotion_code: str + :keyword version: The plan's version. + :paramtype version: str + """ + super(PlanPatchable, self).__init__(**kwargs) + self.name = name + self.publisher = publisher + self.product = product + self.promotion_code = promotion_code + self.version = version + + +class Sku(msrest.serialization.Model): + """SKU for the resource. + + All required parameters must be populated in order to send to Azure. + + :ivar name: Required. The SKU name. + :vartype name: str + :ivar tier: The SKU tier. + :vartype tier: str + :ivar size: The SKU size. + :vartype size: str + :ivar family: The SKU family. + :vartype family: str + :ivar model: The SKU model. + :vartype model: str + :ivar capacity: The SKU capacity. + :vartype capacity: int + """ + + _validation = { + 'name': {'required': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'tier': {'key': 'tier', 'type': 'str'}, + 'size': {'key': 'size', 'type': 'str'}, + 'family': {'key': 'family', 'type': 'str'}, + 'model': {'key': 'model', 'type': 'str'}, + 'capacity': {'key': 'capacity', 'type': 'int'}, + } + + def __init__( + self, + *, + name: str, + tier: Optional[str] = None, + size: Optional[str] = None, + family: Optional[str] = None, + model: Optional[str] = None, + capacity: Optional[int] = None, + **kwargs + ): + """ + :keyword name: Required. The SKU name. + :paramtype name: str + :keyword tier: The SKU tier. + :paramtype tier: str + :keyword size: The SKU size. + :paramtype size: str + :keyword family: The SKU family. + :paramtype family: str + :keyword model: The SKU model. + :paramtype model: str + :keyword capacity: The SKU capacity. + :paramtype capacity: int + """ + super(Sku, self).__init__(**kwargs) + self.name = name + self.tier = tier + self.size = size + self.family = family + self.model = model + self.capacity = capacity + + +class UpdateAccessDefinition(msrest.serialization.Model): + """Update access request definition. + + All required parameters must be populated in order to send to Azure. + + :ivar approver: The approver name. + :vartype approver: str + :ivar metadata: Required. The JIT request metadata. + :vartype metadata: ~azure.mgmt.managedapplication.v2019_07_01.models.JitRequestMetadata + :ivar status: Required. The JIT status. Known values are: "NotSpecified", "Elevate", "Remove". + :vartype status: str or ~azure.mgmt.managedapplication.v2019_07_01.models.Status + :ivar sub_status: Required. The JIT status. Known values are: "NotSpecified", "Approved", + "Denied", "Failed", "Expired", "Timeout". + :vartype sub_status: str or ~azure.mgmt.managedapplication.v2019_07_01.models.Substatus + """ + + _validation = { + 'metadata': {'required': True}, + 'status': {'required': True}, + 'sub_status': {'required': True}, + } + + _attribute_map = { + 'approver': {'key': 'approver', 'type': 'str'}, + 'metadata': {'key': 'metadata', 'type': 'JitRequestMetadata'}, + 'status': {'key': 'status', 'type': 'str'}, + 'sub_status': {'key': 'subStatus', 'type': 'str'}, + } + + def __init__( + self, + *, + metadata: "_models.JitRequestMetadata", + status: Union[str, "_models.Status"], + sub_status: Union[str, "_models.Substatus"], + approver: Optional[str] = None, + **kwargs + ): + """ + :keyword approver: The approver name. + :paramtype approver: str + :keyword metadata: Required. The JIT request metadata. + :paramtype metadata: ~azure.mgmt.managedapplication.v2019_07_01.models.JitRequestMetadata + :keyword status: Required. The JIT status. Known values are: "NotSpecified", "Elevate", + "Remove". + :paramtype status: str or ~azure.mgmt.managedapplication.v2019_07_01.models.Status + :keyword sub_status: Required. The JIT status. Known values are: "NotSpecified", "Approved", + "Denied", "Failed", "Expired", "Timeout". + :paramtype sub_status: str or ~azure.mgmt.managedapplication.v2019_07_01.models.Substatus + """ + super(UpdateAccessDefinition, self).__init__(**kwargs) + self.approver = approver + self.metadata = metadata + self.status = status + self.sub_status = sub_status + + +class UserAssignedResourceIdentity(msrest.serialization.Model): + """Represents the user assigned identity that is contained within the UserAssignedIdentities dictionary on ResourceIdentity. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar principal_id: The principal id of user assigned identity. + :vartype principal_id: str + :ivar tenant_id: The tenant id of user assigned identity. + :vartype tenant_id: str + """ + + _validation = { + 'principal_id': {'readonly': True}, + 'tenant_id': {'readonly': True}, + } + + _attribute_map = { + 'principal_id': {'key': 'principalId', 'type': 'str'}, + 'tenant_id': {'key': 'tenantId', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(UserAssignedResourceIdentity, self).__init__(**kwargs) + self.principal_id = None + self.tenant_id = None diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2019_07_01/models/_patch.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2019_07_01/models/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2019_07_01/models/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2019_07_01/operations/__init__.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2019_07_01/operations/__init__.py new file mode 100644 index 000000000000..b93ecbbe65e2 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2019_07_01/operations/__init__.py @@ -0,0 +1,24 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._application_client_operations import ApplicationClientOperationsMixin +from ._applications_operations import ApplicationsOperations +from ._application_definitions_operations import ApplicationDefinitionsOperations +from ._jit_requests_operations import JitRequestsOperations + +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk +__all__ = [ + 'ApplicationClientOperationsMixin', + 'ApplicationsOperations', + 'ApplicationDefinitionsOperations', + 'JitRequestsOperations', +] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2019_07_01/operations/_application_client_operations.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2019_07_01/operations/_application_client_operations.py new file mode 100644 index 000000000000..721232ce9294 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2019_07_01/operations/_application_client_operations.py @@ -0,0 +1,134 @@ +# 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.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._vendor import MixinABC, _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_operations_request( + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.Solutions/operations") + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + +class ApplicationClientOperationsMixin(MixinABC): + + @distributed_trace + def list_operations( + self, + **kwargs: Any + ) -> Iterable[_models.OperationListResult]: + """Lists all of the available Microsoft.Solutions REST API operations. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either OperationListResult or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.managedapplication.v2019_07_01.models.OperationListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # 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', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_operations_request( + api_version=api_version, + template_url=self.list_operations.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_operations_request( + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list_operations.metadata = {'url': "/providers/Microsoft.Solutions/operations"} # type: ignore diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2019_07_01/operations/_application_definitions_operations.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2019_07_01/operations/_application_definitions_operations.py new file mode 100644 index 000000000000..d988e30b18b3 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2019_07_01/operations/_application_definitions_operations.py @@ -0,0 +1,1158 @@ +# 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.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._vendor import MixinABC, _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_request( + resource_group_name: str, + application_definition_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "applicationDefinitionName": _SERIALIZER.url("application_definition_name", application_definition_name, 'str', max_length=64, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_delete_request( + resource_group_name: str, + application_definition_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "applicationDefinitionName": _SERIALIZER.url("application_definition_name", application_definition_name, 'str', max_length=64, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_create_or_update_request( + resource_group_name: str, + application_definition_name: str, + subscription_id: str, + *, + json: Optional[_models.ApplicationDefinition] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "applicationDefinitionName": _SERIALIZER.url("application_definition_name", application_definition_name, 'str', max_length=64, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_update_request( + subscription_id: str, + resource_group_name: str, + application_definition_name: str, + *, + json: Optional[_models.ApplicationDefinitionPatchable] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "applicationDefinitionName": _SERIALIZER.url("application_definition_name", application_definition_name, 'str', max_length=64, min_length=3), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_list_by_resource_group_request( + resource_group_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_list_by_subscription_request( + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Solutions/applicationDefinitions") + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_get_by_id_request( + resource_group_name: str, + application_definition_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "applicationDefinitionName": _SERIALIZER.url("application_definition_name", application_definition_name, 'str', max_length=64, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_delete_by_id_request( + resource_group_name: str, + application_definition_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "applicationDefinitionName": _SERIALIZER.url("application_definition_name", application_definition_name, 'str', max_length=64, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_create_or_update_by_id_request( + resource_group_name: str, + application_definition_name: str, + subscription_id: str, + *, + json: Optional[_models.ApplicationDefinition] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "applicationDefinitionName": _SERIALIZER.url("application_definition_name", application_definition_name, 'str', max_length=64, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_update_by_id_request( + subscription_id: str, + resource_group_name: str, + application_definition_name: str, + *, + json: Optional[_models.ApplicationDefinitionPatchable] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "applicationDefinitionName": _SERIALIZER.url("application_definition_name", application_definition_name, 'str', max_length=64, min_length=3), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + +class ApplicationDefinitionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.managedapplication.v2019_07_01.ApplicationClient`'s + :attr:`application_definitions` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + + @distributed_trace + def get( + self, + resource_group_name: str, + application_definition_name: str, + **kwargs: Any + ) -> Optional[_models.ApplicationDefinition]: + """Gets the managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. + :type application_definition_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ApplicationDefinition, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2019_07_01.models.ApplicationDefinition or None + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.ApplicationDefinition]] + + + request = build_get_request( + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('ApplicationDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore + + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + application_definition_name: str, + **kwargs: Any + ) -> None: + """Deletes the managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition to delete. + :type application_definition_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_request( + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore + + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + application_definition_name: str, + parameters: _models.ApplicationDefinition, + **kwargs: Any + ) -> _models.ApplicationDefinition: + """Create or update managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. + :type application_definition_name: str + :param parameters: Parameters supplied to the create or update an managed application + definition. + :type parameters: ~azure.mgmt.managedapplication.v2019_07_01.models.ApplicationDefinition + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ApplicationDefinition, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2019_07_01.models.ApplicationDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationDefinition] + + _json = self._serialize.body(parameters, 'ApplicationDefinition') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # 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, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('ApplicationDefinition', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('ApplicationDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore + + + @distributed_trace + def update( + self, + resource_group_name: str, + application_definition_name: str, + parameters: _models.ApplicationDefinitionPatchable, + **kwargs: Any + ) -> _models.ApplicationDefinition: + """Updates the managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. + :type application_definition_name: str + :param parameters: Parameters supplied to the update a managed application definition. + :type parameters: + ~azure.mgmt.managedapplication.v2019_07_01.models.ApplicationDefinitionPatchable + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ApplicationDefinition, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2019_07_01.models.ApplicationDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationDefinition] + + _json = self._serialize.body(parameters, 'ApplicationDefinitionPatchable') + + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ApplicationDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore + + + @distributed_trace + def list_by_resource_group( + self, + resource_group_name: str, + **kwargs: Any + ) -> Iterable[_models.ApplicationDefinitionListResult]: + """Lists the managed application definitions in a resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ApplicationDefinitionListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.managedapplication.v2019_07_01.models.ApplicationDefinitionListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationDefinitionListResult] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_resource_group.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ApplicationDefinitionListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions"} # type: ignore + + @distributed_trace + def list_by_subscription( + self, + **kwargs: Any + ) -> Iterable[_models.ApplicationDefinitionListResult]: + """Lists the managed application definitions in a subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ApplicationDefinitionListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.managedapplication.v2019_07_01.models.ApplicationDefinitionListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationDefinitionListResult] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ApplicationDefinitionListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Solutions/applicationDefinitions"} # type: ignore + + @distributed_trace + def get_by_id( + self, + resource_group_name: str, + application_definition_name: str, + **kwargs: Any + ) -> Optional[_models.ApplicationDefinition]: + """Gets the managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. + :type application_definition_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ApplicationDefinition, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2019_07_01.models.ApplicationDefinition or None + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.ApplicationDefinition]] + + + request = build_get_by_id_request( + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_by_id.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('ApplicationDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_by_id.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore + + + @distributed_trace + def delete_by_id( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + application_definition_name: str, + **kwargs: Any + ) -> None: + """Deletes the managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. + :type application_definition_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_by_id_request( + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete_by_id.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete_by_id.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore + + + @distributed_trace + def create_or_update_by_id( + self, + resource_group_name: str, + application_definition_name: str, + parameters: _models.ApplicationDefinition, + **kwargs: Any + ) -> _models.ApplicationDefinition: + """Creates or updates a managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. + :type application_definition_name: str + :param parameters: Parameters supplied to the create or update a managed application + definition. + :type parameters: ~azure.mgmt.managedapplication.v2019_07_01.models.ApplicationDefinition + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ApplicationDefinition, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2019_07_01.models.ApplicationDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationDefinition] + + _json = self._serialize.body(parameters, 'ApplicationDefinition') + + request = build_create_or_update_by_id_request( + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + 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'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # 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, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('ApplicationDefinition', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('ApplicationDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_or_update_by_id.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore + + + @distributed_trace + def update_by_id( + self, + resource_group_name: str, + application_definition_name: str, + parameters: _models.ApplicationDefinitionPatchable, + **kwargs: Any + ) -> _models.ApplicationDefinition: + """Updates the managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. + :type application_definition_name: str + :param parameters: Parameters supplied to the update a managed application definition. + :type parameters: + ~azure.mgmt.managedapplication.v2019_07_01.models.ApplicationDefinitionPatchable + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ApplicationDefinition, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2019_07_01.models.ApplicationDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationDefinition] + + _json = self._serialize.body(parameters, 'ApplicationDefinitionPatchable') + + request = build_update_by_id_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.update_by_id.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ApplicationDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + update_by_id.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore + diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2019_07_01/operations/_applications_operations.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2019_07_01/operations/_applications_operations.py new file mode 100644 index 000000000000..ed0c400d9b49 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2019_07_01/operations/_applications_operations.py @@ -0,0 +1,2090 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast + +from msrest import Serializer + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from .._vendor import MixinABC, _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_request( + resource_group_name: str, + application_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "applicationName": _SERIALIZER.url("application_name", application_name, 'str', max_length=64, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_delete_request_initial( + resource_group_name: str, + application_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "applicationName": _SERIALIZER.url("application_name", application_name, 'str', max_length=64, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_create_or_update_request_initial( + resource_group_name: str, + application_name: str, + subscription_id: str, + *, + json: Optional[_models.Application] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "applicationName": _SERIALIZER.url("application_name", application_name, 'str', max_length=64, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_update_request_initial( + resource_group_name: str, + application_name: str, + subscription_id: str, + *, + json: Optional[_models.ApplicationPatchable] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "applicationName": _SERIALIZER.url("application_name", application_name, 'str', max_length=64, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_list_by_resource_group_request( + resource_group_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_list_by_subscription_request( + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Solutions/applications") + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_get_by_id_request( + application_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/{applicationId}") + path_format_arguments = { + "applicationId": _SERIALIZER.url("application_id", application_id, 'str', skip_quote=True), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_delete_by_id_request_initial( + application_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/{applicationId}") + path_format_arguments = { + "applicationId": _SERIALIZER.url("application_id", application_id, 'str', skip_quote=True), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_create_or_update_by_id_request_initial( + application_id: str, + *, + json: Optional[_models.Application] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/{applicationId}") + path_format_arguments = { + "applicationId": _SERIALIZER.url("application_id", application_id, 'str', skip_quote=True), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_update_by_id_request_initial( + application_id: str, + *, + json: Optional[_models.ApplicationPatchable] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/{applicationId}") + path_format_arguments = { + "applicationId": _SERIALIZER.url("application_id", application_id, 'str', skip_quote=True), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_refresh_permissions_request_initial( + resource_group_name: str, + application_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}/refreshPermissions") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "applicationName": _SERIALIZER.url("application_name", application_name, 'str', max_length=64, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_list_allowed_upgrade_plans_request( + subscription_id: str, + resource_group_name: str, + application_name: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}/listAllowedUpgradePlans") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "applicationName": _SERIALIZER.url("application_name", application_name, 'str', max_length=64, min_length=3), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_update_access_request_initial( + subscription_id: str, + resource_group_name: str, + application_name: str, + *, + json: Optional[_models.UpdateAccessDefinition] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}/updateAccess") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "applicationName": _SERIALIZER.url("application_name", application_name, 'str', max_length=64, min_length=3), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_list_tokens_request( + subscription_id: str, + resource_group_name: str, + application_name: str, + *, + json: Optional[_models.ListTokenRequest] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}/listTokens") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "applicationName": _SERIALIZER.url("application_name", application_name, 'str', max_length=64, min_length=3), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + +class ApplicationsOperations: # pylint: disable=too-many-public-methods + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.managedapplication.v2019_07_01.ApplicationClient`'s + :attr:`applications` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + + @distributed_trace + def get( + self, + resource_group_name: str, + application_name: str, + **kwargs: Any + ) -> Optional[_models.Application]: + """Gets the managed application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_name: The name of the managed application. + :type application_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Application, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2019_07_01.models.Application or None + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.Application]] + + + request = build_get_request( + resource_group_name=resource_group_name, + application_name=application_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('Application', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}"} # type: ignore + + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + application_name: str, + **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + application_name=application_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}"} # type: ignore + + + @distributed_trace + def begin_delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + application_name: str, + **kwargs: Any + ) -> LROPoller[None]: + """Deletes the managed application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_name: The name of the managed application. + :type application_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._delete_initial( # type: ignore + resource_group_name=resource_group_name, + application_name=application_name, + api_version=api_version, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}"} # type: ignore + + def _create_or_update_initial( + self, + resource_group_name: str, + application_name: str, + parameters: _models.Application, + **kwargs: Any + ) -> _models.Application: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Application] + + _json = self._serialize.body(parameters, 'Application') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + application_name=application_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('Application', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('Application', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}"} # type: ignore + + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + application_name: str, + parameters: _models.Application, + **kwargs: Any + ) -> LROPoller[_models.Application]: + """Creates or updates a managed application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_name: The name of the managed application. + :type application_name: str + :param parameters: Parameters supplied to the create or update a managed application. + :type parameters: ~azure.mgmt.managedapplication.v2019_07_01.models.Application + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Application or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.managedapplication.v2019_07_01.models.Application] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Application] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._create_or_update_initial( # type: ignore + resource_group_name=resource_group_name, + application_name=application_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('Application', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}"} # type: ignore + + def _update_initial( + self, + resource_group_name: str, + application_name: str, + parameters: Optional[_models.ApplicationPatchable] = None, + **kwargs: Any + ) -> _models.ApplicationPatchable: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationPatchable] + + if parameters is not None: + _json = self._serialize.body(parameters, 'ApplicationPatchable') + else: + _json = None + + request = build_update_request_initial( + resource_group_name=resource_group_name, + application_name=application_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('ApplicationPatchable', pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize('ApplicationPatchable', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}"} # type: ignore + + + @distributed_trace + def begin_update( + self, + resource_group_name: str, + application_name: str, + parameters: Optional[_models.ApplicationPatchable] = None, + **kwargs: Any + ) -> LROPoller[_models.ApplicationPatchable]: + """Updates an existing managed application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_name: The name of the managed application. + :type application_name: str + :param parameters: Parameters supplied to update an existing managed application. Default value + is None. + :type parameters: ~azure.mgmt.managedapplication.v2019_07_01.models.ApplicationPatchable + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ApplicationPatchable or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.managedapplication.v2019_07_01.models.ApplicationPatchable] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationPatchable] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._update_initial( # type: ignore + resource_group_name=resource_group_name, + application_name=application_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('ApplicationPatchable', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}"} # type: ignore + + @distributed_trace + def list_by_resource_group( + self, + resource_group_name: str, + **kwargs: Any + ) -> Iterable[_models.ApplicationListResult]: + """Lists all the applications within a resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ApplicationListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.managedapplication.v2019_07_01.models.ApplicationListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationListResult] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_resource_group.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ApplicationListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications"} # type: ignore + + @distributed_trace + def list_by_subscription( + self, + **kwargs: Any + ) -> Iterable[_models.ApplicationListResult]: + """Lists all the applications within a subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ApplicationListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.managedapplication.v2019_07_01.models.ApplicationListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationListResult] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ApplicationListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Solutions/applications"} # type: ignore + + @distributed_trace + def get_by_id( + self, + application_id: str, + **kwargs: Any + ) -> Optional[_models.Application]: + """Gets the managed application. + + :param application_id: The fully qualified ID of the managed application, including the managed + application name and the managed application resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/Microsoft.Solutions/applications/{application-name}. + :type application_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Application, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2019_07_01.models.Application or None + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.Application]] + + + request = build_get_by_id_request( + application_id=application_id, + api_version=api_version, + template_url=self.get_by_id.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('Application', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_by_id.metadata = {'url': "/{applicationId}"} # type: ignore + + + def _delete_by_id_initial( # pylint: disable=inconsistent-return-statements + self, + application_id: str, + **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_by_id_request_initial( + application_id=application_id, + api_version=api_version, + template_url=self._delete_by_id_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_by_id_initial.metadata = {'url': "/{applicationId}"} # type: ignore + + + @distributed_trace + def begin_delete_by_id( # pylint: disable=inconsistent-return-statements + self, + application_id: str, + **kwargs: Any + ) -> LROPoller[None]: + """Deletes the managed application. + + :param application_id: The fully qualified ID of the managed application, including the managed + application name and the managed application resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/Microsoft.Solutions/applications/{application-name}. + :type application_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._delete_by_id_initial( # type: ignore + application_id=application_id, + api_version=api_version, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete_by_id.metadata = {'url': "/{applicationId}"} # type: ignore + + def _create_or_update_by_id_initial( + self, + application_id: str, + parameters: _models.Application, + **kwargs: Any + ) -> _models.Application: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Application] + + _json = self._serialize.body(parameters, 'Application') + + request = build_create_or_update_by_id_request_initial( + application_id=application_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._create_or_update_by_id_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('Application', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('Application', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_by_id_initial.metadata = {'url': "/{applicationId}"} # type: ignore + + + @distributed_trace + def begin_create_or_update_by_id( + self, + application_id: str, + parameters: _models.Application, + **kwargs: Any + ) -> LROPoller[_models.Application]: + """Creates or updates a managed application. + + :param application_id: The fully qualified ID of the managed application, including the managed + application name and the managed application resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/Microsoft.Solutions/applications/{application-name}. + :type application_id: str + :param parameters: Parameters supplied to the create or update a managed application. + :type parameters: ~azure.mgmt.managedapplication.v2019_07_01.models.Application + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Application or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.managedapplication.v2019_07_01.models.Application] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Application] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._create_or_update_by_id_initial( # type: ignore + application_id=application_id, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('Application', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update_by_id.metadata = {'url': "/{applicationId}"} # type: ignore + + def _update_by_id_initial( + self, + application_id: str, + parameters: Optional[_models.ApplicationPatchable] = None, + **kwargs: Any + ) -> _models.ApplicationPatchable: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationPatchable] + + if parameters is not None: + _json = self._serialize.body(parameters, 'ApplicationPatchable') + else: + _json = None + + request = build_update_by_id_request_initial( + application_id=application_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._update_by_id_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('ApplicationPatchable', pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize('ApplicationPatchable', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _update_by_id_initial.metadata = {'url': "/{applicationId}"} # type: ignore + + + @distributed_trace + def begin_update_by_id( + self, + application_id: str, + parameters: Optional[_models.ApplicationPatchable] = None, + **kwargs: Any + ) -> LROPoller[_models.ApplicationPatchable]: + """Updates an existing managed application. + + :param application_id: The fully qualified ID of the managed application, including the managed + application name and the managed application resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/Microsoft.Solutions/applications/{application-name}. + :type application_id: str + :param parameters: Parameters supplied to update an existing managed application. Default value + is None. + :type parameters: ~azure.mgmt.managedapplication.v2019_07_01.models.ApplicationPatchable + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ApplicationPatchable or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.managedapplication.v2019_07_01.models.ApplicationPatchable] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationPatchable] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._update_by_id_initial( # type: ignore + application_id=application_id, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('ApplicationPatchable', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_update_by_id.metadata = {'url': "/{applicationId}"} # type: ignore + + def _refresh_permissions_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + application_name: str, + **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_refresh_permissions_request_initial( + resource_group_name=resource_group_name, + application_name=application_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._refresh_permissions_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _refresh_permissions_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}/refreshPermissions"} # type: ignore + + + @distributed_trace + def begin_refresh_permissions( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + application_name: str, + **kwargs: Any + ) -> LROPoller[None]: + """Refresh Permissions for application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_name: The name of the managed application. + :type application_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._refresh_permissions_initial( # type: ignore + resource_group_name=resource_group_name, + application_name=application_name, + api_version=api_version, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'location'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_refresh_permissions.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}/refreshPermissions"} # type: ignore + + @distributed_trace + def list_allowed_upgrade_plans( + self, + resource_group_name: str, + application_name: str, + **kwargs: Any + ) -> _models.AllowedUpgradePlansResult: + """List allowed upgrade plans for application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_name: The name of the managed application. + :type application_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AllowedUpgradePlansResult, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2019_07_01.models.AllowedUpgradePlansResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AllowedUpgradePlansResult] + + + request = build_list_allowed_upgrade_plans_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + application_name=application_name, + api_version=api_version, + template_url=self.list_allowed_upgrade_plans.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('AllowedUpgradePlansResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_allowed_upgrade_plans.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}/listAllowedUpgradePlans"} # type: ignore + + + def _update_access_initial( + self, + resource_group_name: str, + application_name: str, + parameters: _models.UpdateAccessDefinition, + **kwargs: Any + ) -> Optional[_models.UpdateAccessDefinition]: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.UpdateAccessDefinition]] + + _json = self._serialize.body(parameters, 'UpdateAccessDefinition') + + request = build_update_access_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + application_name=application_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._update_access_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 202: + deserialized = self._deserialize('UpdateAccessDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _update_access_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}/updateAccess"} # type: ignore + + + @distributed_trace + def begin_update_access( + self, + resource_group_name: str, + application_name: str, + parameters: _models.UpdateAccessDefinition, + **kwargs: Any + ) -> LROPoller[_models.UpdateAccessDefinition]: + """Update access for application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_name: The name of the managed application. + :type application_name: str + :param parameters: Request body parameters to list tokens. + :type parameters: ~azure.mgmt.managedapplication.v2019_07_01.models.UpdateAccessDefinition + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either UpdateAccessDefinition or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.managedapplication.v2019_07_01.models.UpdateAccessDefinition] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.UpdateAccessDefinition] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._update_access_initial( # type: ignore + resource_group_name=resource_group_name, + application_name=application_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('UpdateAccessDefinition', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'location'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_update_access.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}/updateAccess"} # type: ignore + + @distributed_trace + def list_tokens( + self, + resource_group_name: str, + application_name: str, + parameters: _models.ListTokenRequest, + **kwargs: Any + ) -> _models.ManagedIdentityTokenResult: + """List tokens for application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_name: The name of the managed application. + :type application_name: str + :param parameters: Request body parameters to list tokens. + :type parameters: ~azure.mgmt.managedapplication.v2019_07_01.models.ListTokenRequest + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ManagedIdentityTokenResult, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2019_07_01.models.ManagedIdentityTokenResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ManagedIdentityTokenResult] + + _json = self._serialize.body(parameters, 'ListTokenRequest') + + request = build_list_tokens_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + application_name=application_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.list_tokens.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ManagedIdentityTokenResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_tokens.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}/listTokens"} # type: ignore + diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2019_07_01/operations/_jit_requests_operations.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2019_07_01/operations/_jit_requests_operations.py new file mode 100644 index 000000000000..36f68be5f27d --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2019_07_01/operations/_jit_requests_operations.py @@ -0,0 +1,736 @@ +# 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, Union, cast + +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.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from .._vendor import MixinABC, _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_request( + resource_group_name: str, + jit_request_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/jitRequests/{jitRequestName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "jitRequestName": _SERIALIZER.url("jit_request_name", jit_request_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_create_or_update_request_initial( + resource_group_name: str, + jit_request_name: str, + subscription_id: str, + *, + json: Optional[_models.JitRequestDefinition] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/jitRequests/{jitRequestName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "jitRequestName": _SERIALIZER.url("jit_request_name", jit_request_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_update_request( + resource_group_name: str, + jit_request_name: str, + subscription_id: str, + *, + json: Optional[_models.JitRequestPatchable] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/jitRequests/{jitRequestName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "jitRequestName": _SERIALIZER.url("jit_request_name", jit_request_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request( + resource_group_name: str, + jit_request_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/jitRequests/{jitRequestName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "jitRequestName": _SERIALIZER.url("jit_request_name", jit_request_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_list_by_subscription_request( + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Solutions/jitRequests") + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_list_by_resource_group_request( + resource_group_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/jitRequests") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + +class JitRequestsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.managedapplication.v2019_07_01.ApplicationClient`'s + :attr:`jit_requests` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + + @distributed_trace + def get( + self, + resource_group_name: str, + jit_request_name: str, + **kwargs: Any + ) -> Optional[_models.JitRequestDefinition]: + """Gets the JIT request. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param jit_request_name: The name of the JIT request. + :type jit_request_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JitRequestDefinition, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2019_07_01.models.JitRequestDefinition or None + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.JitRequestDefinition]] + + + request = build_get_request( + resource_group_name=resource_group_name, + jit_request_name=jit_request_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('JitRequestDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/jitRequests/{jitRequestName}"} # type: ignore + + + def _create_or_update_initial( + self, + resource_group_name: str, + jit_request_name: str, + parameters: _models.JitRequestDefinition, + **kwargs: Any + ) -> _models.JitRequestDefinition: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.JitRequestDefinition] + + _json = self._serialize.body(parameters, 'JitRequestDefinition') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + jit_request_name=jit_request_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('JitRequestDefinition', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('JitRequestDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/jitRequests/{jitRequestName}"} # type: ignore + + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + jit_request_name: str, + parameters: _models.JitRequestDefinition, + **kwargs: Any + ) -> LROPoller[_models.JitRequestDefinition]: + """Creates or updates the JIT request. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param jit_request_name: The name of the JIT request. + :type jit_request_name: str + :param parameters: Parameters supplied to the update JIT request. + :type parameters: ~azure.mgmt.managedapplication.v2019_07_01.models.JitRequestDefinition + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either JitRequestDefinition or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.managedapplication.v2019_07_01.models.JitRequestDefinition] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.JitRequestDefinition] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._create_or_update_initial( # type: ignore + resource_group_name=resource_group_name, + jit_request_name=jit_request_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('JitRequestDefinition', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/jitRequests/{jitRequestName}"} # type: ignore + + @distributed_trace + def update( + self, + resource_group_name: str, + jit_request_name: str, + parameters: _models.JitRequestPatchable, + **kwargs: Any + ) -> _models.JitRequestDefinition: + """Updates the JIT request. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param jit_request_name: The name of the JIT request. + :type jit_request_name: str + :param parameters: Parameters supplied to the update JIT request. + :type parameters: ~azure.mgmt.managedapplication.v2019_07_01.models.JitRequestPatchable + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JitRequestDefinition, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2019_07_01.models.JitRequestDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.JitRequestDefinition] + + _json = self._serialize.body(parameters, 'JitRequestPatchable') + + request = build_update_request( + resource_group_name=resource_group_name, + jit_request_name=jit_request_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('JitRequestDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/jitRequests/{jitRequestName}"} # type: ignore + + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + jit_request_name: str, + **kwargs: Any + ) -> None: + """Deletes the JIT request. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param jit_request_name: The name of the JIT request. + :type jit_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 + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_request( + resource_group_name=resource_group_name, + jit_request_name=jit_request_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/jitRequests/{jitRequestName}"} # type: ignore + + + @distributed_trace + def list_by_subscription( + self, + **kwargs: Any + ) -> _models.JitRequestDefinitionListResult: + """Lists all JIT requests within the subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JitRequestDefinitionListResult, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2019_07_01.models.JitRequestDefinitionListResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.JitRequestDefinitionListResult] + + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('JitRequestDefinitionListResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Solutions/jitRequests"} # type: ignore + + + @distributed_trace + def list_by_resource_group( + self, + resource_group_name: str, + **kwargs: Any + ) -> _models.JitRequestDefinitionListResult: + """Retrieves all JIT requests within the 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: JitRequestDefinitionListResult, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2019_07_01.models.JitRequestDefinitionListResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.JitRequestDefinitionListResult] + + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_resource_group.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('JitRequestDefinitionListResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/jitRequests"} # type: ignore + diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2019_07_01/operations/_patch.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2019_07_01/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2019_07_01/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2019_07_01/py.typed b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2019_07_01/py.typed new file mode 100644 index 000000000000..e5aff4f83af8 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2019_07_01/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2020_08_21_preview/__init__.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2020_08_21_preview/__init__.py new file mode 100644 index 000000000000..2e61ca12e56a --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2020_08_21_preview/__init__.py @@ -0,0 +1,23 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._application_client import ApplicationClient +from ._version import VERSION + +__version__ = VERSION + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk +__all__ = ['ApplicationClient'] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2020_08_21_preview/_application_client.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2020_08_21_preview/_application_client.py new file mode 100644 index 000000000000..28ca3ba7cb2a --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2020_08_21_preview/_application_client.py @@ -0,0 +1,112 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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 ApplicationClientConfiguration +from .operations import ApplicationClientOperationsMixin, ApplicationDefinitionsOperations, ApplicationsOperations, JitRequestsOperations + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential + +class ApplicationClient(ApplicationClientOperationsMixin): + """ARM applications. + + :ivar applications: ApplicationsOperations operations + :vartype applications: + azure.mgmt.managedapplication.v2020_08_21_preview.operations.ApplicationsOperations + :ivar application_definitions: ApplicationDefinitionsOperations operations + :vartype application_definitions: + azure.mgmt.managedapplication.v2020_08_21_preview.operations.ApplicationDefinitionsOperations + :ivar jit_requests: JitRequestsOperations operations + :vartype jit_requests: + azure.mgmt.managedapplication.v2020_08_21_preview.operations.JitRequestsOperations + :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 "2020-08-21-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + """ + + def __init__( + self, + credential: "TokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = ApplicationClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.applications = ApplicationsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.application_definitions = ApplicationDefinitionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.jit_requests = JitRequestsOperations( + 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: () -> ApplicationClient + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (Any) -> None + self._client.__exit__(*exc_details) diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2020_08_21_preview/_configuration.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2020_08_21_preview/_configuration.py new file mode 100644 index 000000000000..6fa6d86eeef5 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2020_08_21_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 ApplicationClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes + """Configuration for ApplicationClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials.TokenCredential + :param subscription_id: The ID of the target subscription. + :type subscription_id: str + :keyword api_version: Api Version. Default value is "2020-08-21-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(ApplicationClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2020-08-21-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-managedapplication/{}'.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/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2020_08_21_preview/_metadata.json b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2020_08_21_preview/_metadata.json new file mode 100644 index 000000000000..e06e3f3393d5 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2020_08_21_preview/_metadata.json @@ -0,0 +1,123 @@ +{ + "chosen_version": "2020-08-21-preview", + "total_api_version_list": ["2020-08-21-preview"], + "client": { + "name": "ApplicationClient", + "filename": "_application_client", + "description": "ARM applications.", + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": null, + "azure_arm": true, + "has_lro_operations": true, + "client_side_validation": false, + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ApplicationClientConfiguration\"], \"._operations_mixin\": [\"ApplicationClientOperationsMixin\"]}, \"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\": [\"ApplicationClientConfiguration\"], \"._operations_mixin\": [\"ApplicationClientOperationsMixin\"]}, \"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": { + "applications": "ApplicationsOperations", + "application_definitions": "ApplicationDefinitionsOperations", + "jit_requests": "JitRequestsOperations" + }, + "operation_mixins": { + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Iterable\"]}, \"azurecore\": {\"azure.core.paging\": [\"ItemPaged\"]}}, \"regular\": {\"local\": {\".\": [[\"models\", \"_models\"]]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"AsyncIterable\"]}, \"azurecore\": {\"azure.core.async_paging\": [\"AsyncItemPaged\"]}}, \"regular\": {\"local\": {\"..\": [[\"models\", \"_models\"]]}}}", + "operations": { + "list_operations" : { + "sync": { + "signature": "def list_operations(\n self,\n **kwargs # type: Any\n):\n # type: (...) -\u003e Iterable[_models.OperationListResult]\n", + "doc": "\"\"\"Lists all of the available Microsoft.Solutions REST API operations.\n\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: An iterator like instance of either OperationListResult or the result of cls(response)\n:rtype:\n ~azure.core.paging.ItemPaged[~azure.mgmt.managedapplication.v2020_08_21_preview.models.OperationListResult]\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"", + "call": "**kwargs" + }, + "async": { + "coroutine": false, + "signature": "def list_operations(\n self,\n **kwargs: Any\n) -\u003e AsyncIterable[_models.OperationListResult]:\n", + "doc": "\"\"\"Lists all of the available Microsoft.Solutions REST API operations.\n\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: An iterator like instance of either OperationListResult or the result of cls(response)\n:rtype:\n ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.managedapplication.v2020_08_21_preview.models.OperationListResult]\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"", + "call": "**kwargs" + } + } + } + } +} \ No newline at end of file diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2020_08_21_preview/_patch.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2020_08_21_preview/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2020_08_21_preview/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2020_08_21_preview/_vendor.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2020_08_21_preview/_vendor.py new file mode 100644 index 000000000000..bf1845cabc0f --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2020_08_21_preview/_vendor.py @@ -0,0 +1,45 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from abc import ABC +from typing import TYPE_CHECKING + +from azure.core.pipeline.transport import HttpRequest + +from ._configuration import ApplicationClientConfiguration + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from msrest import Deserializer, Serializer + + from azure.core import PipelineClient + +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) + +class MixinABC(ABC): + """DO NOT use this class. It is for internal typing use only.""" + _client: "PipelineClient" + _config: ApplicationClientConfiguration + _serialize: "Serializer" + _deserialize: "Deserializer" diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2020_08_21_preview/_version.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2020_08_21_preview/_version.py new file mode 100644 index 000000000000..e5754a47ce68 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2020_08_21_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/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2020_08_21_preview/aio/__init__.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2020_08_21_preview/aio/__init__.py new file mode 100644 index 000000000000..c90626a31421 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2020_08_21_preview/aio/__init__.py @@ -0,0 +1,20 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._application_client import ApplicationClient + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk +__all__ = ['ApplicationClient'] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2020_08_21_preview/aio/_application_client.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2020_08_21_preview/aio/_application_client.py new file mode 100644 index 000000000000..fbc30e52d6f6 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2020_08_21_preview/aio/_application_client.py @@ -0,0 +1,109 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# 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 ApplicationClientConfiguration +from .operations import ApplicationClientOperationsMixin, ApplicationDefinitionsOperations, ApplicationsOperations, JitRequestsOperations + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + +class ApplicationClient(ApplicationClientOperationsMixin): + """ARM applications. + + :ivar applications: ApplicationsOperations operations + :vartype applications: + azure.mgmt.managedapplication.v2020_08_21_preview.aio.operations.ApplicationsOperations + :ivar application_definitions: ApplicationDefinitionsOperations operations + :vartype application_definitions: + azure.mgmt.managedapplication.v2020_08_21_preview.aio.operations.ApplicationDefinitionsOperations + :ivar jit_requests: JitRequestsOperations operations + :vartype jit_requests: + azure.mgmt.managedapplication.v2020_08_21_preview.aio.operations.JitRequestsOperations + :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 "2020-08-21-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = ApplicationClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.applications = ApplicationsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.application_definitions = ApplicationDefinitionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.jit_requests = JitRequestsOperations( + 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) -> "ApplicationClient": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2020_08_21_preview/aio/_configuration.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2020_08_21_preview/aio/_configuration.py new file mode 100644 index 000000000000..cbd0925840bb --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2020_08_21_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 ApplicationClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes + """Configuration for ApplicationClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :param subscription_id: The ID of the target subscription. + :type subscription_id: str + :keyword api_version: Api Version. Default value is "2020-08-21-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(ApplicationClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2020-08-21-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-managedapplication/{}'.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/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2020_08_21_preview/aio/_patch.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2020_08_21_preview/aio/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2020_08_21_preview/aio/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2020_08_21_preview/aio/_vendor.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2020_08_21_preview/aio/_vendor.py new file mode 100644 index 000000000000..da14e4f71f0e --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2020_08_21_preview/aio/_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 abc import ABC +from typing import TYPE_CHECKING + +from azure.core.pipeline.transport import HttpRequest + +from ._configuration import ApplicationClientConfiguration + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from msrest import Deserializer, Serializer + + from azure.core import AsyncPipelineClient + + +class MixinABC(ABC): + """DO NOT use this class. It is for internal typing use only.""" + _client: "AsyncPipelineClient" + _config: ApplicationClientConfiguration + _serialize: "Serializer" + _deserialize: "Deserializer" diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2020_08_21_preview/aio/operations/__init__.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2020_08_21_preview/aio/operations/__init__.py new file mode 100644 index 000000000000..b93ecbbe65e2 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2020_08_21_preview/aio/operations/__init__.py @@ -0,0 +1,24 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._application_client_operations import ApplicationClientOperationsMixin +from ._applications_operations import ApplicationsOperations +from ._application_definitions_operations import ApplicationDefinitionsOperations +from ._jit_requests_operations import JitRequestsOperations + +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk +__all__ = [ + 'ApplicationClientOperationsMixin', + 'ApplicationsOperations', + 'ApplicationDefinitionsOperations', + 'JitRequestsOperations', +] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2020_08_21_preview/aio/operations/_application_client_operations.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2020_08_21_preview/aio/operations/_application_client_operations.py new file mode 100644 index 000000000000..810068c9dfe1 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2020_08_21_preview/aio/operations/_application_client_operations.py @@ -0,0 +1,105 @@ +# 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.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._application_client_operations import build_list_operations_request +from .._vendor import MixinABC +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class ApplicationClientOperationsMixin(MixinABC): + + @distributed_trace + def list_operations( + self, + **kwargs: Any + ) -> AsyncIterable[_models.OperationListResult]: + """Lists all of the available Microsoft.Solutions REST API operations. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either OperationListResult or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.managedapplication.v2020_08_21_preview.models.OperationListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-21-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', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_operations_request( + api_version=api_version, + template_url=self.list_operations.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_operations_request( + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list_operations.metadata = {'url': "/providers/Microsoft.Solutions/operations"} # type: ignore diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2020_08_21_preview/aio/operations/_application_definitions_operations.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2020_08_21_preview/aio/operations/_application_definitions_operations.py new file mode 100644 index 000000000000..3f5ea9e92c70 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2020_08_21_preview/aio/operations/_application_definitions_operations.py @@ -0,0 +1,763 @@ +# 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.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._application_definitions_operations import build_create_or_update_by_id_request, build_create_or_update_request, build_delete_by_id_request, build_delete_request, build_get_by_id_request, build_get_request, build_list_by_resource_group_request, build_list_by_subscription_request, build_update_by_id_request, build_update_request +from .._vendor import MixinABC +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class ApplicationDefinitionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.managedapplication.v2020_08_21_preview.aio.ApplicationClient`'s + :attr:`application_definitions` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + application_definition_name: str, + **kwargs: Any + ) -> Optional[_models.ApplicationDefinition]: + """Gets the managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. + :type application_definition_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ApplicationDefinition, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2020_08_21_preview.models.ApplicationDefinition or None + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-21-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.ApplicationDefinition]] + + + request = build_get_request( + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('ApplicationDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore + + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + application_definition_name: str, + **kwargs: Any + ) -> None: + """Deletes the managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition to delete. + :type application_definition_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-21-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_request( + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore + + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + application_definition_name: str, + parameters: _models.ApplicationDefinition, + **kwargs: Any + ) -> _models.ApplicationDefinition: + """Creates a new managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. + :type application_definition_name: str + :param parameters: Parameters supplied to the create or update an managed application + definition. + :type parameters: + ~azure.mgmt.managedapplication.v2020_08_21_preview.models.ApplicationDefinition + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ApplicationDefinition, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2020_08_21_preview.models.ApplicationDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-21-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationDefinition] + + _json = self._serialize.body(parameters, 'ApplicationDefinition') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # 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, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('ApplicationDefinition', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('ApplicationDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore + + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + application_definition_name: str, + parameters: _models.ApplicationDefinitionPatchable, + **kwargs: Any + ) -> _models.ApplicationDefinition: + """Updates the managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. + :type application_definition_name: str + :param parameters: Parameters supplied to the update a managed application definition. + :type parameters: + ~azure.mgmt.managedapplication.v2020_08_21_preview.models.ApplicationDefinitionPatchable + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ApplicationDefinition, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2020_08_21_preview.models.ApplicationDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-21-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationDefinition] + + _json = self._serialize.body(parameters, 'ApplicationDefinitionPatchable') + + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ApplicationDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore + + + @distributed_trace + def list_by_resource_group( + self, + resource_group_name: str, + **kwargs: Any + ) -> AsyncIterable[_models.ApplicationDefinitionListResult]: + """Lists the managed application definitions in a resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ApplicationDefinitionListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.managedapplication.v2020_08_21_preview.models.ApplicationDefinitionListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-21-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationDefinitionListResult] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_resource_group.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ApplicationDefinitionListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions"} # type: ignore + + @distributed_trace + def list_by_subscription( + self, + **kwargs: Any + ) -> AsyncIterable[_models.ApplicationDefinitionListResult]: + """Lists the managed application definitions in a subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ApplicationDefinitionListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.managedapplication.v2020_08_21_preview.models.ApplicationDefinitionListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-21-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationDefinitionListResult] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ApplicationDefinitionListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Solutions/applicationDefinitions"} # type: ignore + + @distributed_trace_async + async def get_by_id( + self, + resource_group_name: str, + application_definition_name: str, + **kwargs: Any + ) -> Optional[_models.ApplicationDefinition]: + """Gets the managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. + :type application_definition_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ApplicationDefinition, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2020_08_21_preview.models.ApplicationDefinition or None + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-21-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.ApplicationDefinition]] + + + request = build_get_by_id_request( + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_by_id.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('ApplicationDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_by_id.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore + + + @distributed_trace_async + async def delete_by_id( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + application_definition_name: str, + **kwargs: Any + ) -> None: + """Deletes the managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. + :type application_definition_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-21-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_by_id_request( + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete_by_id.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete_by_id.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore + + + @distributed_trace_async + async def create_or_update_by_id( + self, + resource_group_name: str, + application_definition_name: str, + parameters: _models.ApplicationDefinition, + **kwargs: Any + ) -> _models.ApplicationDefinition: + """Creates or updates a managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. + :type application_definition_name: str + :param parameters: Parameters supplied to the create or update a managed application + definition. + :type parameters: + ~azure.mgmt.managedapplication.v2020_08_21_preview.models.ApplicationDefinition + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ApplicationDefinition, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2020_08_21_preview.models.ApplicationDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-21-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationDefinition] + + _json = self._serialize.body(parameters, 'ApplicationDefinition') + + request = build_create_or_update_by_id_request( + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + 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'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # 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, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('ApplicationDefinition', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('ApplicationDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_or_update_by_id.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore + + + @distributed_trace_async + async def update_by_id( + self, + resource_group_name: str, + application_definition_name: str, + parameters: _models.ApplicationDefinitionPatchable, + **kwargs: Any + ) -> _models.ApplicationDefinition: + """Updates the managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. + :type application_definition_name: str + :param parameters: Parameters supplied to the update a managed application definition. + :type parameters: + ~azure.mgmt.managedapplication.v2020_08_21_preview.models.ApplicationDefinitionPatchable + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ApplicationDefinition, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2020_08_21_preview.models.ApplicationDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-21-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationDefinition] + + _json = self._serialize.body(parameters, 'ApplicationDefinitionPatchable') + + request = build_update_by_id_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.update_by_id.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ApplicationDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + update_by_id.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore + diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2020_08_21_preview/aio/operations/_applications_operations.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2020_08_21_preview/aio/operations/_applications_operations.py new file mode 100644 index 000000000000..306fe8052a38 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2020_08_21_preview/aio/operations/_applications_operations.py @@ -0,0 +1,1480 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union, cast + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._applications_operations import build_create_or_update_by_id_request_initial, build_create_or_update_request_initial, build_delete_by_id_request_initial, build_delete_request_initial, build_get_by_id_request, build_get_request, build_list_allowed_upgrade_plans_request, build_list_by_resource_group_request, build_list_by_subscription_request, build_list_tokens_request, build_refresh_permissions_request_initial, build_update_access_request_initial, build_update_by_id_request_initial, build_update_request +from .._vendor import MixinABC +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class ApplicationsOperations: # pylint: disable=too-many-public-methods + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.managedapplication.v2020_08_21_preview.aio.ApplicationClient`'s + :attr:`applications` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + application_name: str, + **kwargs: Any + ) -> Optional[_models.Application]: + """Gets the managed application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_name: The name of the managed application. + :type application_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Application, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2020_08_21_preview.models.Application or None + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-21-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.Application]] + + + request = build_get_request( + resource_group_name=resource_group_name, + application_name=application_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('Application', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}"} # type: ignore + + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + application_name: str, + **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-21-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + application_name=application_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}"} # type: ignore + + + @distributed_trace_async + async def begin_delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + application_name: str, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes the managed application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_name: The name of the managed application. + :type application_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-21-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._delete_initial( # type: ignore + resource_group_name=resource_group_name, + application_name=application_name, + api_version=api_version, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}"} # type: ignore + + async def _create_or_update_initial( + self, + resource_group_name: str, + application_name: str, + parameters: _models.Application, + **kwargs: Any + ) -> _models.Application: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-21-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Application] + + _json = self._serialize.body(parameters, 'Application') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + application_name=application_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('Application', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('Application', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}"} # type: ignore + + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + application_name: str, + parameters: _models.Application, + **kwargs: Any + ) -> AsyncLROPoller[_models.Application]: + """Creates or update managed application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_name: The name of the managed application. + :type application_name: str + :param parameters: Parameters supplied to the create or update a managed application. + :type parameters: ~azure.mgmt.managedapplication.v2020_08_21_preview.models.Application + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either Application or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.managedapplication.v2020_08_21_preview.models.Application] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-21-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Application] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._create_or_update_initial( # type: ignore + resource_group_name=resource_group_name, + application_name=application_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('Application', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}"} # type: ignore + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + application_name: str, + parameters: Optional[_models.ApplicationPatchable] = None, + **kwargs: Any + ) -> _models.ApplicationPatchable: + """Updates an existing managed application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_name: The name of the managed application. + :type application_name: str + :param parameters: Parameters supplied to update an existing managed application. Default value + is None. + :type parameters: + ~azure.mgmt.managedapplication.v2020_08_21_preview.models.ApplicationPatchable + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ApplicationPatchable, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2020_08_21_preview.models.ApplicationPatchable + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-21-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationPatchable] + + if parameters is not None: + _json = self._serialize.body(parameters, 'ApplicationPatchable') + else: + _json = None + + request = build_update_request( + resource_group_name=resource_group_name, + application_name=application_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('ApplicationPatchable', pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize('ApplicationPatchable', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}"} # type: ignore + + + @distributed_trace + def list_by_resource_group( + self, + resource_group_name: str, + **kwargs: Any + ) -> AsyncIterable[_models.ApplicationListResult]: + """Gets all the applications within a resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ApplicationListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.managedapplication.v2020_08_21_preview.models.ApplicationListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-21-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationListResult] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_resource_group.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ApplicationListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications"} # type: ignore + + @distributed_trace + def list_by_subscription( + self, + **kwargs: Any + ) -> AsyncIterable[_models.ApplicationListResult]: + """Lists all the applications within a subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ApplicationListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.managedapplication.v2020_08_21_preview.models.ApplicationListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-21-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationListResult] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ApplicationListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Solutions/applications"} # type: ignore + + @distributed_trace_async + async def get_by_id( + self, + application_id: str, + **kwargs: Any + ) -> Optional[_models.Application]: + """Gets the managed application. + + :param application_id: The fully qualified ID of the managed application, including the managed + application name and the managed application resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/Microsoft.Solutions/applications/{application-name}. + :type application_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Application, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2020_08_21_preview.models.Application or None + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-21-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.Application]] + + + request = build_get_by_id_request( + application_id=application_id, + api_version=api_version, + template_url=self.get_by_id.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('Application', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_by_id.metadata = {'url': "/{applicationId}"} # type: ignore + + + async def _delete_by_id_initial( # pylint: disable=inconsistent-return-statements + self, + application_id: str, + **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-21-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_by_id_request_initial( + application_id=application_id, + api_version=api_version, + template_url=self._delete_by_id_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_by_id_initial.metadata = {'url': "/{applicationId}"} # type: ignore + + + @distributed_trace_async + async def begin_delete_by_id( # pylint: disable=inconsistent-return-statements + self, + application_id: str, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes the managed application. + + :param application_id: The fully qualified ID of the managed application, including the managed + application name and the managed application resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/Microsoft.Solutions/applications/{application-name}. + :type application_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-21-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._delete_by_id_initial( # type: ignore + application_id=application_id, + api_version=api_version, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete_by_id.metadata = {'url': "/{applicationId}"} # type: ignore + + async def _create_or_update_by_id_initial( + self, + application_id: str, + parameters: _models.Application, + **kwargs: Any + ) -> _models.Application: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-21-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Application] + + _json = self._serialize.body(parameters, 'Application') + + request = build_create_or_update_by_id_request_initial( + application_id=application_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._create_or_update_by_id_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('Application', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('Application', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_by_id_initial.metadata = {'url': "/{applicationId}"} # type: ignore + + + @distributed_trace_async + async def begin_create_or_update_by_id( + self, + application_id: str, + parameters: _models.Application, + **kwargs: Any + ) -> AsyncLROPoller[_models.Application]: + """Creates or updates a managed application. + + :param application_id: The fully qualified ID of the managed application, including the managed + application name and the managed application resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/Microsoft.Solutions/applications/{application-name}. + :type application_id: str + :param parameters: Parameters supplied to the create or update a managed application. + :type parameters: ~azure.mgmt.managedapplication.v2020_08_21_preview.models.Application + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either Application or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.managedapplication.v2020_08_21_preview.models.Application] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-21-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Application] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._create_or_update_by_id_initial( # type: ignore + application_id=application_id, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('Application', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update_by_id.metadata = {'url': "/{applicationId}"} # type: ignore + + async def _update_by_id_initial( + self, + application_id: str, + parameters: Optional[_models.ApplicationPatchable] = None, + **kwargs: Any + ) -> _models.ApplicationPatchable: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-21-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationPatchable] + + if parameters is not None: + _json = self._serialize.body(parameters, 'ApplicationPatchable') + else: + _json = None + + request = build_update_by_id_request_initial( + application_id=application_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._update_by_id_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('ApplicationPatchable', pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize('ApplicationPatchable', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _update_by_id_initial.metadata = {'url': "/{applicationId}"} # type: ignore + + + @distributed_trace_async + async def begin_update_by_id( + self, + application_id: str, + parameters: Optional[_models.ApplicationPatchable] = None, + **kwargs: Any + ) -> AsyncLROPoller[_models.ApplicationPatchable]: + """Updates an existing managed application. + + :param application_id: The fully qualified ID of the managed application, including the managed + application name and the managed application resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/Microsoft.Solutions/applications/{application-name}. + :type application_id: str + :param parameters: Parameters supplied to update an existing managed application. Default value + is None. + :type parameters: + ~azure.mgmt.managedapplication.v2020_08_21_preview.models.ApplicationPatchable + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ApplicationPatchable or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.managedapplication.v2020_08_21_preview.models.ApplicationPatchable] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-21-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationPatchable] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._update_by_id_initial( # type: ignore + application_id=application_id, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('ApplicationPatchable', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_update_by_id.metadata = {'url': "/{applicationId}"} # type: ignore + + async def _refresh_permissions_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + application_name: str, + **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-21-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_refresh_permissions_request_initial( + resource_group_name=resource_group_name, + application_name=application_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._refresh_permissions_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _refresh_permissions_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}/refreshPermissions"} # type: ignore + + + @distributed_trace_async + async def begin_refresh_permissions( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + application_name: str, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Refresh Permissions for application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_name: The name of the managed application. + :type application_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-21-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._refresh_permissions_initial( # type: ignore + resource_group_name=resource_group_name, + application_name=application_name, + api_version=api_version, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'location'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_refresh_permissions.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}/refreshPermissions"} # type: ignore + + @distributed_trace_async + async def list_allowed_upgrade_plans( + self, + resource_group_name: str, + application_name: str, + **kwargs: Any + ) -> _models.AllowedUpgradePlansResult: + """List allowed upgrade plans for application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_name: The name of the managed application. + :type application_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AllowedUpgradePlansResult, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2020_08_21_preview.models.AllowedUpgradePlansResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-21-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AllowedUpgradePlansResult] + + + request = build_list_allowed_upgrade_plans_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + application_name=application_name, + api_version=api_version, + template_url=self.list_allowed_upgrade_plans.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('AllowedUpgradePlansResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_allowed_upgrade_plans.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}/listAllowedUpgradePlans"} # type: ignore + + + async def _update_access_initial( + self, + resource_group_name: str, + application_name: str, + parameters: _models.UpdateAccessDefinition, + **kwargs: Any + ) -> Optional[_models.UpdateAccessDefinition]: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-21-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.UpdateAccessDefinition]] + + _json = self._serialize.body(parameters, 'UpdateAccessDefinition') + + request = build_update_access_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + application_name=application_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._update_access_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 202: + deserialized = self._deserialize('UpdateAccessDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _update_access_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}/updateAccess"} # type: ignore + + + @distributed_trace_async + async def begin_update_access( + self, + resource_group_name: str, + application_name: str, + parameters: _models.UpdateAccessDefinition, + **kwargs: Any + ) -> AsyncLROPoller[_models.UpdateAccessDefinition]: + """Update access for application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_name: The name of the managed application. + :type application_name: str + :param parameters: Request body parameters to update access. + :type parameters: + ~azure.mgmt.managedapplication.v2020_08_21_preview.models.UpdateAccessDefinition + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either UpdateAccessDefinition or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.managedapplication.v2020_08_21_preview.models.UpdateAccessDefinition] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-21-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.UpdateAccessDefinition] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._update_access_initial( # type: ignore + resource_group_name=resource_group_name, + application_name=application_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('UpdateAccessDefinition', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'location'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_update_access.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}/updateAccess"} # type: ignore + + @distributed_trace_async + async def list_tokens( + self, + resource_group_name: str, + application_name: str, + parameters: _models.ListTokenRequest, + **kwargs: Any + ) -> _models.ManagedIdentityTokenResult: + """List tokens for application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_name: The name of the managed application. + :type application_name: str + :param parameters: Request body parameters to list tokens. + :type parameters: ~azure.mgmt.managedapplication.v2020_08_21_preview.models.ListTokenRequest + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ManagedIdentityTokenResult, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2020_08_21_preview.models.ManagedIdentityTokenResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-21-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ManagedIdentityTokenResult] + + _json = self._serialize.body(parameters, 'ListTokenRequest') + + request = build_list_tokens_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + application_name=application_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.list_tokens.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ManagedIdentityTokenResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_tokens.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}/listTokens"} # type: ignore + diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2020_08_21_preview/aio/operations/_jit_requests_operations.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2020_08_21_preview/aio/operations/_jit_requests_operations.py new file mode 100644 index 000000000000..2d05b10b6b50 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2020_08_21_preview/aio/operations/_jit_requests_operations.py @@ -0,0 +1,505 @@ +# 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, Union, cast + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._jit_requests_operations import build_create_or_update_request_initial, build_delete_request, build_get_request, build_list_by_resource_group_request, build_list_by_subscription_request, build_update_request +from .._vendor import MixinABC +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class JitRequestsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.managedapplication.v2020_08_21_preview.aio.ApplicationClient`'s + :attr:`jit_requests` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + jit_request_name: str, + **kwargs: Any + ) -> Optional[_models.JitRequestDefinition]: + """Gets the JIT request. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param jit_request_name: The name of the JIT request. + :type jit_request_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JitRequestDefinition, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2020_08_21_preview.models.JitRequestDefinition or None + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-21-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.JitRequestDefinition]] + + + request = build_get_request( + resource_group_name=resource_group_name, + jit_request_name=jit_request_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('JitRequestDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/jitRequests/{jitRequestName}"} # type: ignore + + + async def _create_or_update_initial( + self, + resource_group_name: str, + jit_request_name: str, + parameters: _models.JitRequestDefinition, + **kwargs: Any + ) -> _models.JitRequestDefinition: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-21-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.JitRequestDefinition] + + _json = self._serialize.body(parameters, 'JitRequestDefinition') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + jit_request_name=jit_request_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('JitRequestDefinition', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('JitRequestDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/jitRequests/{jitRequestName}"} # type: ignore + + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + jit_request_name: str, + parameters: _models.JitRequestDefinition, + **kwargs: Any + ) -> AsyncLROPoller[_models.JitRequestDefinition]: + """Creates or updates the JIT request. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param jit_request_name: The name of the JIT request. + :type jit_request_name: str + :param parameters: Parameters supplied to the update JIT request. + :type parameters: + ~azure.mgmt.managedapplication.v2020_08_21_preview.models.JitRequestDefinition + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either JitRequestDefinition or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.managedapplication.v2020_08_21_preview.models.JitRequestDefinition] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-21-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.JitRequestDefinition] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._create_or_update_initial( # type: ignore + resource_group_name=resource_group_name, + jit_request_name=jit_request_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('JitRequestDefinition', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/jitRequests/{jitRequestName}"} # type: ignore + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + jit_request_name: str, + parameters: _models.JitRequestPatchable, + **kwargs: Any + ) -> _models.JitRequestDefinition: + """Updates the JIT request. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param jit_request_name: The name of the JIT request. + :type jit_request_name: str + :param parameters: Parameters supplied to the update JIT request. + :type parameters: ~azure.mgmt.managedapplication.v2020_08_21_preview.models.JitRequestPatchable + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JitRequestDefinition, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2020_08_21_preview.models.JitRequestDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-21-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.JitRequestDefinition] + + _json = self._serialize.body(parameters, 'JitRequestPatchable') + + request = build_update_request( + resource_group_name=resource_group_name, + jit_request_name=jit_request_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('JitRequestDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/jitRequests/{jitRequestName}"} # type: ignore + + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + jit_request_name: str, + **kwargs: Any + ) -> None: + """Deletes the JIT request. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param jit_request_name: The name of the JIT request. + :type jit_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 + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-21-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_request( + resource_group_name=resource_group_name, + jit_request_name=jit_request_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/jitRequests/{jitRequestName}"} # type: ignore + + + @distributed_trace_async + async def list_by_subscription( + self, + **kwargs: Any + ) -> _models.JitRequestDefinitionListResult: + """Lists all JIT requests within the subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JitRequestDefinitionListResult, or the result of cls(response) + :rtype: + ~azure.mgmt.managedapplication.v2020_08_21_preview.models.JitRequestDefinitionListResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-21-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.JitRequestDefinitionListResult] + + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('JitRequestDefinitionListResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Solutions/jitRequests"} # type: ignore + + + @distributed_trace_async + async def list_by_resource_group( + self, + resource_group_name: str, + **kwargs: Any + ) -> _models.JitRequestDefinitionListResult: + """Lists all JIT requests within the 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: JitRequestDefinitionListResult, or the result of cls(response) + :rtype: + ~azure.mgmt.managedapplication.v2020_08_21_preview.models.JitRequestDefinitionListResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-21-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.JitRequestDefinitionListResult] + + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_resource_group.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('JitRequestDefinitionListResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/jitRequests"} # type: ignore + diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2020_08_21_preview/aio/operations/_patch.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2020_08_21_preview/aio/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2020_08_21_preview/aio/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2020_08_21_preview/models/__init__.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2020_08_21_preview/models/__init__.py new file mode 100644 index 000000000000..f444904cb87f --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2020_08_21_preview/models/__init__.py @@ -0,0 +1,149 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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 AllowedUpgradePlansResult +from ._models_py3 import Application +from ._models_py3 import ApplicationArtifact +from ._models_py3 import ApplicationAuthorization +from ._models_py3 import ApplicationBillingDetailsDefinition +from ._models_py3 import ApplicationClientDetails +from ._models_py3 import ApplicationDefinition +from ._models_py3 import ApplicationDefinitionArtifact +from ._models_py3 import ApplicationDefinitionListResult +from ._models_py3 import ApplicationDefinitionPatchable +from ._models_py3 import ApplicationDeploymentPolicy +from ._models_py3 import ApplicationJitAccessPolicy +from ._models_py3 import ApplicationListResult +from ._models_py3 import ApplicationManagementPolicy +from ._models_py3 import ApplicationNotificationEndpoint +from ._models_py3 import ApplicationNotificationPolicy +from ._models_py3 import ApplicationPackageContact +from ._models_py3 import ApplicationPackageLockingPolicyDefinition +from ._models_py3 import ApplicationPackageSupportUrls +from ._models_py3 import ApplicationPatchable +from ._models_py3 import ApplicationPolicy +from ._models_py3 import ApplicationPropertiesPatchable +from ._models_py3 import ErrorAdditionalInfo +from ._models_py3 import ErrorDetail +from ._models_py3 import ErrorResponse +from ._models_py3 import GenericResource +from ._models_py3 import Identity +from ._models_py3 import JitApproverDefinition +from ._models_py3 import JitAuthorizationPolicies +from ._models_py3 import JitRequestDefinition +from ._models_py3 import JitRequestDefinitionListResult +from ._models_py3 import JitRequestMetadata +from ._models_py3 import JitRequestPatchable +from ._models_py3 import JitSchedulingPolicy +from ._models_py3 import ListTokenRequest +from ._models_py3 import ManagedIdentityToken +from ._models_py3 import ManagedIdentityTokenResult +from ._models_py3 import Operation +from ._models_py3 import OperationAutoGenerated +from ._models_py3 import OperationDisplay +from ._models_py3 import OperationDisplayAutoGenerated +from ._models_py3 import OperationListResult +from ._models_py3 import OperationListResultAutoGenerated +from ._models_py3 import Plan +from ._models_py3 import PlanPatchable +from ._models_py3 import Resource +from ._models_py3 import Sku +from ._models_py3 import UpdateAccessDefinition +from ._models_py3 import UserAssignedResourceIdentity + + +from ._application_client_enums import ( + ActionType, + ApplicationArtifactName, + ApplicationArtifactType, + ApplicationDefinitionArtifactName, + ApplicationLockLevel, + ApplicationManagementMode, + DeploymentMode, + JitApprovalMode, + JitApproverType, + JitRequestState, + JitSchedulingType, + Origin, + ProvisioningState, + ResourceIdentityType, + Status, + Substatus, +) +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk +__all__ = [ + 'AllowedUpgradePlansResult', + 'Application', + 'ApplicationArtifact', + 'ApplicationAuthorization', + 'ApplicationBillingDetailsDefinition', + 'ApplicationClientDetails', + 'ApplicationDefinition', + 'ApplicationDefinitionArtifact', + 'ApplicationDefinitionListResult', + 'ApplicationDefinitionPatchable', + 'ApplicationDeploymentPolicy', + 'ApplicationJitAccessPolicy', + 'ApplicationListResult', + 'ApplicationManagementPolicy', + 'ApplicationNotificationEndpoint', + 'ApplicationNotificationPolicy', + 'ApplicationPackageContact', + 'ApplicationPackageLockingPolicyDefinition', + 'ApplicationPackageSupportUrls', + 'ApplicationPatchable', + 'ApplicationPolicy', + 'ApplicationPropertiesPatchable', + 'ErrorAdditionalInfo', + 'ErrorDetail', + 'ErrorResponse', + 'GenericResource', + 'Identity', + 'JitApproverDefinition', + 'JitAuthorizationPolicies', + 'JitRequestDefinition', + 'JitRequestDefinitionListResult', + 'JitRequestMetadata', + 'JitRequestPatchable', + 'JitSchedulingPolicy', + 'ListTokenRequest', + 'ManagedIdentityToken', + 'ManagedIdentityTokenResult', + 'Operation', + 'OperationAutoGenerated', + 'OperationDisplay', + 'OperationDisplayAutoGenerated', + 'OperationListResult', + 'OperationListResultAutoGenerated', + 'Plan', + 'PlanPatchable', + 'Resource', + 'Sku', + 'UpdateAccessDefinition', + 'UserAssignedResourceIdentity', + 'ActionType', + 'ApplicationArtifactName', + 'ApplicationArtifactType', + 'ApplicationDefinitionArtifactName', + 'ApplicationLockLevel', + 'ApplicationManagementMode', + 'DeploymentMode', + 'JitApprovalMode', + 'JitApproverType', + 'JitRequestState', + 'JitSchedulingType', + 'Origin', + 'ProvisioningState', + 'ResourceIdentityType', + 'Status', + 'Substatus', +] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2020_08_21_preview/models/_application_client_enums.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2020_08_21_preview/models/_application_client_enums.py new file mode 100644 index 000000000000..890f1a84757e --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2020_08_21_preview/models/_application_client_enums.py @@ -0,0 +1,157 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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 azure.core import CaseInsensitiveEnumMeta + + +class ActionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. + """ + + INTERNAL = "Internal" + +class ApplicationArtifactName(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The managed application artifact name. + """ + + NOT_SPECIFIED = "NotSpecified" + VIEW_DEFINITION = "ViewDefinition" + AUTHORIZATIONS = "Authorizations" + CUSTOM_ROLE_DEFINITION = "CustomRoleDefinition" + +class ApplicationArtifactType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The managed application artifact type. + """ + + NOT_SPECIFIED = "NotSpecified" + TEMPLATE = "Template" + CUSTOM = "Custom" + +class ApplicationDefinitionArtifactName(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The managed application artifact name. + """ + + NOT_SPECIFIED = "NotSpecified" + APPLICATION_RESOURCE_TEMPLATE = "ApplicationResourceTemplate" + CREATE_UI_DEFINITION = "CreateUiDefinition" + MAIN_TEMPLATE_PARAMETERS = "MainTemplateParameters" + +class ApplicationLockLevel(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The managed application lock level. + """ + + CAN_NOT_DELETE = "CanNotDelete" + READ_ONLY = "ReadOnly" + NONE = "None" + +class ApplicationManagementMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The management mode. + """ + + NOT_SPECIFIED = "NotSpecified" + UNMANAGED = "Unmanaged" + MANAGED = "Managed" + +class DeploymentMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The deployment mode. + """ + + NOT_SPECIFIED = "NotSpecified" + INCREMENTAL = "Incremental" + COMPLETE = "Complete" + +class JitApprovalMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The Jit approval mode. + """ + + NOT_SPECIFIED = "NotSpecified" + AUTO_APPROVE = "AutoApprove" + MANUAL_APPROVE = "ManualApprove" + +class JitApproverType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The approver type. + """ + + USER = "user" + GROUP = "group" + +class JitRequestState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The JIT request state. + """ + + NOT_SPECIFIED = "NotSpecified" + PENDING = "Pending" + APPROVED = "Approved" + DENIED = "Denied" + FAILED = "Failed" + CANCELED = "Canceled" + EXPIRED = "Expired" + TIMEOUT = "Timeout" + +class JitSchedulingType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The JIT request scheduling type. + """ + + NOT_SPECIFIED = "NotSpecified" + ONCE = "Once" + RECURRING = "Recurring" + +class Origin(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit + logs UX. Default value is "user,system" + """ + + USER = "user" + SYSTEM = "system" + USER_SYSTEM = "user,system" + +class ProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Provisioning status of the managed application. + """ + + NOT_SPECIFIED = "NotSpecified" + ACCEPTED = "Accepted" + RUNNING = "Running" + READY = "Ready" + CREATING = "Creating" + CREATED = "Created" + DELETING = "Deleting" + DELETED = "Deleted" + CANCELED = "Canceled" + FAILED = "Failed" + SUCCEEDED = "Succeeded" + UPDATING = "Updating" + +class ResourceIdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The identity type. + """ + + SYSTEM_ASSIGNED = "SystemAssigned" + USER_ASSIGNED = "UserAssigned" + SYSTEM_ASSIGNED_USER_ASSIGNED = "SystemAssigned, UserAssigned" + NONE = "None" + +class Status(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The JIT status. + """ + + NOT_SPECIFIED = "NotSpecified" + ELEVATE = "Elevate" + REMOVE = "Remove" + +class Substatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The sub status. + """ + + NOT_SPECIFIED = "NotSpecified" + APPROVED = "Approved" + DENIED = "Denied" + FAILED = "Failed" + EXPIRED = "Expired" + TIMEOUT = "Timeout" diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2020_08_21_preview/models/_models_py3.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2020_08_21_preview/models/_models_py3.py new file mode 100644 index 000000000000..924a5bf0b9aa --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2020_08_21_preview/models/_models_py3.py @@ -0,0 +1,2606 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for 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 Any, Dict, List, Optional, TYPE_CHECKING, Union + +from azure.core.exceptions import HttpResponseError +import msrest.serialization + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + import __init__ as _models + + +class AllowedUpgradePlansResult(msrest.serialization.Model): + """The array of plan. + + :ivar value: The array of plans. + :vartype value: list[~azure.mgmt.managedapplication.v2020_08_21_preview.models.Plan] + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Plan]'}, + } + + def __init__( + self, + *, + value: Optional[List["_models.Plan"]] = None, + **kwargs + ): + """ + :keyword value: The array of plans. + :paramtype value: list[~azure.mgmt.managedapplication.v2020_08_21_preview.models.Plan] + """ + super(AllowedUpgradePlansResult, self).__init__(**kwargs) + self.value = value + + +class Resource(msrest.serialization.Model): + """Resource information. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Resource ID. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar location: Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'location': {'key': 'location', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + } + + def __init__( + self, + *, + location: Optional[str] = None, + tags: Optional[Dict[str, str]] = None, + **kwargs + ): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + """ + super(Resource, self).__init__(**kwargs) + self.id = None + self.name = None + self.type = None + self.location = location + self.tags = tags + + +class GenericResource(Resource): + """Resource information. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Resource ID. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar location: Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar managed_by: ID of the resource that manages this resource. + :vartype managed_by: str + :ivar sku: The SKU of the resource. + :vartype sku: ~azure.mgmt.managedapplication.v2020_08_21_preview.models.Sku + """ + + _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'}, + 'location': {'key': 'location', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + 'managed_by': {'key': 'managedBy', 'type': 'str'}, + 'sku': {'key': 'sku', 'type': 'Sku'}, + } + + def __init__( + self, + *, + location: Optional[str] = None, + tags: Optional[Dict[str, str]] = None, + managed_by: Optional[str] = None, + sku: Optional["_models.Sku"] = None, + **kwargs + ): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword managed_by: ID of the resource that manages this resource. + :paramtype managed_by: str + :keyword sku: The SKU of the resource. + :paramtype sku: ~azure.mgmt.managedapplication.v2020_08_21_preview.models.Sku + """ + super(GenericResource, self).__init__(location=location, tags=tags, **kwargs) + self.managed_by = managed_by + self.sku = sku + + +class Application(GenericResource): + """Information about managed application. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar id: Resource ID. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar location: Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar managed_by: ID of the resource that manages this resource. + :vartype managed_by: str + :ivar sku: The SKU of the resource. + :vartype sku: ~azure.mgmt.managedapplication.v2020_08_21_preview.models.Sku + :ivar plan: The plan information. + :vartype plan: ~azure.mgmt.managedapplication.v2020_08_21_preview.models.Plan + :ivar kind: Required. The kind of the managed application. Allowed values are MarketPlace and + ServiceCatalog. + :vartype kind: str + :ivar identity: The identity of the resource. + :vartype identity: ~azure.mgmt.managedapplication.v2020_08_21_preview.models.Identity + :ivar managed_resource_group_id: The managed resource group Id. + :vartype managed_resource_group_id: str + :ivar application_definition_id: The fully qualified path of managed application definition Id. + :vartype application_definition_id: str + :ivar parameters: Name and value pairs that define the managed application parameters. It can + be a JObject or a well formed JSON string. + :vartype parameters: any + :ivar outputs: Name and value pairs that define the managed application outputs. + :vartype outputs: any + :ivar provisioning_state: The managed application provisioning state. Known values are: + "NotSpecified", "Accepted", "Running", "Ready", "Creating", "Created", "Deleting", "Deleted", + "Canceled", "Failed", "Succeeded", "Updating". + :vartype provisioning_state: str or + ~azure.mgmt.managedapplication.v2020_08_21_preview.models.ProvisioningState + :ivar billing_details: The managed application billing details. + :vartype billing_details: + ~azure.mgmt.managedapplication.v2020_08_21_preview.models.ApplicationBillingDetailsDefinition + :ivar jit_access_policy: The managed application Jit access policy. + :vartype jit_access_policy: + ~azure.mgmt.managedapplication.v2020_08_21_preview.models.ApplicationJitAccessPolicy + :ivar publisher_tenant_id: The publisher tenant Id. + :vartype publisher_tenant_id: str + :ivar authorizations: The read-only authorizations property that is retrieved from the + application package. + :vartype authorizations: + list[~azure.mgmt.managedapplication.v2020_08_21_preview.models.ApplicationAuthorization] + :ivar management_mode: The managed application management mode. Known values are: + "NotSpecified", "Unmanaged", "Managed". + :vartype management_mode: str or + ~azure.mgmt.managedapplication.v2020_08_21_preview.models.ApplicationManagementMode + :ivar customer_support: The read-only customer support property that is retrieved from the + application package. + :vartype customer_support: + ~azure.mgmt.managedapplication.v2020_08_21_preview.models.ApplicationPackageContact + :ivar support_urls: The read-only support URLs property that is retrieved from the application + package. + :vartype support_urls: + ~azure.mgmt.managedapplication.v2020_08_21_preview.models.ApplicationPackageSupportUrls + :ivar artifacts: The collection of managed application artifacts. + :vartype artifacts: + list[~azure.mgmt.managedapplication.v2020_08_21_preview.models.ApplicationArtifact] + :ivar created_by: The client entity that created the JIT request. + :vartype created_by: + ~azure.mgmt.managedapplication.v2020_08_21_preview.models.ApplicationClientDetails + :ivar updated_by: The client entity that last updated the JIT request. + :vartype updated_by: + ~azure.mgmt.managedapplication.v2020_08_21_preview.models.ApplicationClientDetails + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'kind': {'required': True, 'pattern': r'^[-\w\._,\(\)]+$'}, + 'outputs': {'readonly': True}, + 'provisioning_state': {'readonly': True}, + 'billing_details': {'readonly': True}, + 'publisher_tenant_id': {'readonly': True}, + 'authorizations': {'readonly': True}, + 'management_mode': {'readonly': True}, + 'customer_support': {'readonly': True}, + 'support_urls': {'readonly': True}, + 'artifacts': {'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'}, + 'location': {'key': 'location', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + 'managed_by': {'key': 'managedBy', 'type': 'str'}, + 'sku': {'key': 'sku', 'type': 'Sku'}, + 'plan': {'key': 'plan', 'type': 'Plan'}, + 'kind': {'key': 'kind', 'type': 'str'}, + 'identity': {'key': 'identity', 'type': 'Identity'}, + 'managed_resource_group_id': {'key': 'properties.managedResourceGroupId', 'type': 'str'}, + 'application_definition_id': {'key': 'properties.applicationDefinitionId', 'type': 'str'}, + 'parameters': {'key': 'properties.parameters', 'type': 'object'}, + 'outputs': {'key': 'properties.outputs', 'type': 'object'}, + 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + 'billing_details': {'key': 'properties.billingDetails', 'type': 'ApplicationBillingDetailsDefinition'}, + 'jit_access_policy': {'key': 'properties.jitAccessPolicy', 'type': 'ApplicationJitAccessPolicy'}, + 'publisher_tenant_id': {'key': 'properties.publisherTenantId', 'type': 'str'}, + 'authorizations': {'key': 'properties.authorizations', 'type': '[ApplicationAuthorization]'}, + 'management_mode': {'key': 'properties.managementMode', 'type': 'str'}, + 'customer_support': {'key': 'properties.customerSupport', 'type': 'ApplicationPackageContact'}, + 'support_urls': {'key': 'properties.supportUrls', 'type': 'ApplicationPackageSupportUrls'}, + 'artifacts': {'key': 'properties.artifacts', 'type': '[ApplicationArtifact]'}, + 'created_by': {'key': 'properties.createdBy', 'type': 'ApplicationClientDetails'}, + 'updated_by': {'key': 'properties.updatedBy', 'type': 'ApplicationClientDetails'}, + } + + def __init__( + self, + *, + kind: str, + location: Optional[str] = None, + tags: Optional[Dict[str, str]] = None, + managed_by: Optional[str] = None, + sku: Optional["_models.Sku"] = None, + plan: Optional["_models.Plan"] = None, + identity: Optional["_models.Identity"] = None, + managed_resource_group_id: Optional[str] = None, + application_definition_id: Optional[str] = None, + parameters: Optional[Any] = None, + jit_access_policy: Optional["_models.ApplicationJitAccessPolicy"] = None, + **kwargs + ): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword managed_by: ID of the resource that manages this resource. + :paramtype managed_by: str + :keyword sku: The SKU of the resource. + :paramtype sku: ~azure.mgmt.managedapplication.v2020_08_21_preview.models.Sku + :keyword plan: The plan information. + :paramtype plan: ~azure.mgmt.managedapplication.v2020_08_21_preview.models.Plan + :keyword kind: Required. The kind of the managed application. Allowed values are MarketPlace + and ServiceCatalog. + :paramtype kind: str + :keyword identity: The identity of the resource. + :paramtype identity: ~azure.mgmt.managedapplication.v2020_08_21_preview.models.Identity + :keyword managed_resource_group_id: The managed resource group Id. + :paramtype managed_resource_group_id: str + :keyword application_definition_id: The fully qualified path of managed application definition + Id. + :paramtype application_definition_id: str + :keyword parameters: Name and value pairs that define the managed application parameters. It + can be a JObject or a well formed JSON string. + :paramtype parameters: any + :keyword jit_access_policy: The managed application Jit access policy. + :paramtype jit_access_policy: + ~azure.mgmt.managedapplication.v2020_08_21_preview.models.ApplicationJitAccessPolicy + """ + super(Application, self).__init__(location=location, tags=tags, managed_by=managed_by, sku=sku, **kwargs) + self.plan = plan + self.kind = kind + self.identity = identity + self.managed_resource_group_id = managed_resource_group_id + self.application_definition_id = application_definition_id + self.parameters = parameters + self.outputs = None + self.provisioning_state = None + self.billing_details = None + self.jit_access_policy = jit_access_policy + self.publisher_tenant_id = None + self.authorizations = None + self.management_mode = None + self.customer_support = None + self.support_urls = None + self.artifacts = None + self.created_by = None + self.updated_by = None + + +class ApplicationArtifact(msrest.serialization.Model): + """Managed application artifact. + + All required parameters must be populated in order to send to Azure. + + :ivar name: Required. The managed application artifact name. Known values are: "NotSpecified", + "ViewDefinition", "Authorizations", "CustomRoleDefinition". + :vartype name: str or + ~azure.mgmt.managedapplication.v2020_08_21_preview.models.ApplicationArtifactName + :ivar uri: Required. The managed application artifact blob uri. + :vartype uri: str + :ivar type: Required. The managed application artifact type. Known values are: "NotSpecified", + "Template", "Custom". + :vartype type: str or + ~azure.mgmt.managedapplication.v2020_08_21_preview.models.ApplicationArtifactType + """ + + _validation = { + 'name': {'required': True}, + 'uri': {'required': True}, + 'type': {'required': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'uri': {'key': 'uri', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + } + + def __init__( + self, + *, + name: Union[str, "_models.ApplicationArtifactName"], + uri: str, + type: Union[str, "_models.ApplicationArtifactType"], + **kwargs + ): + """ + :keyword name: Required. The managed application artifact name. Known values are: + "NotSpecified", "ViewDefinition", "Authorizations", "CustomRoleDefinition". + :paramtype name: str or + ~azure.mgmt.managedapplication.v2020_08_21_preview.models.ApplicationArtifactName + :keyword uri: Required. The managed application artifact blob uri. + :paramtype uri: str + :keyword type: Required. The managed application artifact type. Known values are: + "NotSpecified", "Template", "Custom". + :paramtype type: str or + ~azure.mgmt.managedapplication.v2020_08_21_preview.models.ApplicationArtifactType + """ + super(ApplicationArtifact, self).__init__(**kwargs) + self.name = name + self.uri = uri + self.type = type + + +class ApplicationAuthorization(msrest.serialization.Model): + """The managed application provider authorization. + + All required parameters must be populated in order to send to Azure. + + :ivar principal_id: Required. The provider's principal identifier. This is the identity that + the provider will use to call ARM to manage the managed application resources. + :vartype principal_id: str + :ivar role_definition_id: Required. The provider's role definition identifier. This role will + define all the permissions that the provider must have on the managed application's container + resource group. This role definition cannot have permission to delete the resource group. + :vartype role_definition_id: str + """ + + _validation = { + 'principal_id': {'required': True}, + 'role_definition_id': {'required': True}, + } + + _attribute_map = { + 'principal_id': {'key': 'principalId', 'type': 'str'}, + 'role_definition_id': {'key': 'roleDefinitionId', 'type': 'str'}, + } + + def __init__( + self, + *, + principal_id: str, + role_definition_id: str, + **kwargs + ): + """ + :keyword principal_id: Required. The provider's principal identifier. This is the identity that + the provider will use to call ARM to manage the managed application resources. + :paramtype principal_id: str + :keyword role_definition_id: Required. The provider's role definition identifier. This role + will define all the permissions that the provider must have on the managed application's + container resource group. This role definition cannot have permission to delete the resource + group. + :paramtype role_definition_id: str + """ + super(ApplicationAuthorization, self).__init__(**kwargs) + self.principal_id = principal_id + self.role_definition_id = role_definition_id + + +class ApplicationBillingDetailsDefinition(msrest.serialization.Model): + """Managed application billing details definition. + + :ivar resource_usage_id: The managed application resource usage Id. + :vartype resource_usage_id: str + """ + + _attribute_map = { + 'resource_usage_id': {'key': 'resourceUsageId', 'type': 'str'}, + } + + def __init__( + self, + *, + resource_usage_id: Optional[str] = None, + **kwargs + ): + """ + :keyword resource_usage_id: The managed application resource usage Id. + :paramtype resource_usage_id: str + """ + super(ApplicationBillingDetailsDefinition, self).__init__(**kwargs) + self.resource_usage_id = resource_usage_id + + +class ApplicationClientDetails(msrest.serialization.Model): + """The application client details to track the entity creating/updating the managed app resource. + + :ivar oid: The client Oid. + :vartype oid: str + :ivar puid: The client Puid. + :vartype puid: str + :ivar application_id: The client application Id. + :vartype application_id: str + """ + + _attribute_map = { + 'oid': {'key': 'oid', 'type': 'str'}, + 'puid': {'key': 'puid', 'type': 'str'}, + 'application_id': {'key': 'applicationId', 'type': 'str'}, + } + + def __init__( + self, + *, + oid: Optional[str] = None, + puid: Optional[str] = None, + application_id: Optional[str] = None, + **kwargs + ): + """ + :keyword oid: The client Oid. + :paramtype oid: str + :keyword puid: The client Puid. + :paramtype puid: str + :keyword application_id: The client application Id. + :paramtype application_id: str + """ + super(ApplicationClientDetails, self).__init__(**kwargs) + self.oid = oid + self.puid = puid + self.application_id = application_id + + +class ApplicationDefinition(GenericResource): + """Information about managed application definition. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar id: Resource ID. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar location: Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar managed_by: ID of the resource that manages this resource. + :vartype managed_by: str + :ivar sku: The SKU of the resource. + :vartype sku: ~azure.mgmt.managedapplication.v2020_08_21_preview.models.Sku + :ivar lock_level: Required. The managed application lock level. Known values are: + "CanNotDelete", "ReadOnly", "None". + :vartype lock_level: str or + ~azure.mgmt.managedapplication.v2020_08_21_preview.models.ApplicationLockLevel + :ivar display_name: The managed application definition display name. + :vartype display_name: str + :ivar is_enabled: A value indicating whether the package is enabled or not. + :vartype is_enabled: bool + :ivar authorizations: The managed application provider authorizations. + :vartype authorizations: + list[~azure.mgmt.managedapplication.v2020_08_21_preview.models.ApplicationAuthorization] + :ivar artifacts: The collection of managed application artifacts. The portal will use the files + specified as artifacts to construct the user experience of creating a managed application from + a managed application definition. + :vartype artifacts: + list[~azure.mgmt.managedapplication.v2020_08_21_preview.models.ApplicationDefinitionArtifact] + :ivar description: The managed application definition description. + :vartype description: str + :ivar package_file_uri: The managed application definition package file Uri. Use this element. + :vartype package_file_uri: str + :ivar storage_account_id: The storage account id for bring your own storage scenario. + :vartype storage_account_id: str + :ivar main_template: The inline main template json which has resources to be provisioned. It + can be a JObject or well-formed JSON string. + :vartype main_template: any + :ivar create_ui_definition: The createUiDefinition json for the backing template with + Microsoft.Solutions/applications resource. It can be a JObject or well-formed JSON string. + :vartype create_ui_definition: any + :ivar notification_policy: The managed application notification policy. + :vartype notification_policy: + ~azure.mgmt.managedapplication.v2020_08_21_preview.models.ApplicationNotificationPolicy + :ivar locking_policy: The managed application locking policy. + :vartype locking_policy: + ~azure.mgmt.managedapplication.v2020_08_21_preview.models.ApplicationPackageLockingPolicyDefinition + :ivar deployment_policy: The managed application deployment policy. + :vartype deployment_policy: + ~azure.mgmt.managedapplication.v2020_08_21_preview.models.ApplicationDeploymentPolicy + :ivar management_policy: The managed application management policy that determines publisher's + access to the managed resource group. + :vartype management_policy: + ~azure.mgmt.managedapplication.v2020_08_21_preview.models.ApplicationManagementPolicy + :ivar policies: The managed application provider policies. + :vartype policies: + list[~azure.mgmt.managedapplication.v2020_08_21_preview.models.ApplicationPolicy] + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'lock_level': {'required': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'location': {'key': 'location', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + 'managed_by': {'key': 'managedBy', 'type': 'str'}, + 'sku': {'key': 'sku', 'type': 'Sku'}, + 'lock_level': {'key': 'properties.lockLevel', 'type': 'str'}, + 'display_name': {'key': 'properties.displayName', 'type': 'str'}, + 'is_enabled': {'key': 'properties.isEnabled', 'type': 'bool'}, + 'authorizations': {'key': 'properties.authorizations', 'type': '[ApplicationAuthorization]'}, + 'artifacts': {'key': 'properties.artifacts', 'type': '[ApplicationDefinitionArtifact]'}, + 'description': {'key': 'properties.description', 'type': 'str'}, + 'package_file_uri': {'key': 'properties.packageFileUri', 'type': 'str'}, + 'storage_account_id': {'key': 'properties.storageAccountId', 'type': 'str'}, + 'main_template': {'key': 'properties.mainTemplate', 'type': 'object'}, + 'create_ui_definition': {'key': 'properties.createUiDefinition', 'type': 'object'}, + 'notification_policy': {'key': 'properties.notificationPolicy', 'type': 'ApplicationNotificationPolicy'}, + 'locking_policy': {'key': 'properties.lockingPolicy', 'type': 'ApplicationPackageLockingPolicyDefinition'}, + 'deployment_policy': {'key': 'properties.deploymentPolicy', 'type': 'ApplicationDeploymentPolicy'}, + 'management_policy': {'key': 'properties.managementPolicy', 'type': 'ApplicationManagementPolicy'}, + 'policies': {'key': 'properties.policies', 'type': '[ApplicationPolicy]'}, + } + + def __init__( + self, + *, + lock_level: Union[str, "_models.ApplicationLockLevel"], + location: Optional[str] = None, + tags: Optional[Dict[str, str]] = None, + managed_by: Optional[str] = None, + sku: Optional["_models.Sku"] = None, + display_name: Optional[str] = None, + is_enabled: Optional[bool] = None, + authorizations: Optional[List["_models.ApplicationAuthorization"]] = None, + artifacts: Optional[List["_models.ApplicationDefinitionArtifact"]] = None, + description: Optional[str] = None, + package_file_uri: Optional[str] = None, + storage_account_id: Optional[str] = None, + main_template: Optional[Any] = None, + create_ui_definition: Optional[Any] = None, + notification_policy: Optional["_models.ApplicationNotificationPolicy"] = None, + locking_policy: Optional["_models.ApplicationPackageLockingPolicyDefinition"] = None, + deployment_policy: Optional["_models.ApplicationDeploymentPolicy"] = None, + management_policy: Optional["_models.ApplicationManagementPolicy"] = None, + policies: Optional[List["_models.ApplicationPolicy"]] = None, + **kwargs + ): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword managed_by: ID of the resource that manages this resource. + :paramtype managed_by: str + :keyword sku: The SKU of the resource. + :paramtype sku: ~azure.mgmt.managedapplication.v2020_08_21_preview.models.Sku + :keyword lock_level: Required. The managed application lock level. Known values are: + "CanNotDelete", "ReadOnly", "None". + :paramtype lock_level: str or + ~azure.mgmt.managedapplication.v2020_08_21_preview.models.ApplicationLockLevel + :keyword display_name: The managed application definition display name. + :paramtype display_name: str + :keyword is_enabled: A value indicating whether the package is enabled or not. + :paramtype is_enabled: bool + :keyword authorizations: The managed application provider authorizations. + :paramtype authorizations: + list[~azure.mgmt.managedapplication.v2020_08_21_preview.models.ApplicationAuthorization] + :keyword artifacts: The collection of managed application artifacts. The portal will use the + files specified as artifacts to construct the user experience of creating a managed application + from a managed application definition. + :paramtype artifacts: + list[~azure.mgmt.managedapplication.v2020_08_21_preview.models.ApplicationDefinitionArtifact] + :keyword description: The managed application definition description. + :paramtype description: str + :keyword package_file_uri: The managed application definition package file Uri. Use this + element. + :paramtype package_file_uri: str + :keyword storage_account_id: The storage account id for bring your own storage scenario. + :paramtype storage_account_id: str + :keyword main_template: The inline main template json which has resources to be provisioned. It + can be a JObject or well-formed JSON string. + :paramtype main_template: any + :keyword create_ui_definition: The createUiDefinition json for the backing template with + Microsoft.Solutions/applications resource. It can be a JObject or well-formed JSON string. + :paramtype create_ui_definition: any + :keyword notification_policy: The managed application notification policy. + :paramtype notification_policy: + ~azure.mgmt.managedapplication.v2020_08_21_preview.models.ApplicationNotificationPolicy + :keyword locking_policy: The managed application locking policy. + :paramtype locking_policy: + ~azure.mgmt.managedapplication.v2020_08_21_preview.models.ApplicationPackageLockingPolicyDefinition + :keyword deployment_policy: The managed application deployment policy. + :paramtype deployment_policy: + ~azure.mgmt.managedapplication.v2020_08_21_preview.models.ApplicationDeploymentPolicy + :keyword management_policy: The managed application management policy that determines + publisher's access to the managed resource group. + :paramtype management_policy: + ~azure.mgmt.managedapplication.v2020_08_21_preview.models.ApplicationManagementPolicy + :keyword policies: The managed application provider policies. + :paramtype policies: + list[~azure.mgmt.managedapplication.v2020_08_21_preview.models.ApplicationPolicy] + """ + super(ApplicationDefinition, self).__init__(location=location, tags=tags, managed_by=managed_by, sku=sku, **kwargs) + self.lock_level = lock_level + self.display_name = display_name + self.is_enabled = is_enabled + self.authorizations = authorizations + self.artifacts = artifacts + self.description = description + self.package_file_uri = package_file_uri + self.storage_account_id = storage_account_id + self.main_template = main_template + self.create_ui_definition = create_ui_definition + self.notification_policy = notification_policy + self.locking_policy = locking_policy + self.deployment_policy = deployment_policy + self.management_policy = management_policy + self.policies = policies + + +class ApplicationDefinitionArtifact(msrest.serialization.Model): + """Application definition artifact. + + All required parameters must be populated in order to send to Azure. + + :ivar name: Required. The managed application definition artifact name. Known values are: + "NotSpecified", "ApplicationResourceTemplate", "CreateUiDefinition", "MainTemplateParameters". + :vartype name: str or + ~azure.mgmt.managedapplication.v2020_08_21_preview.models.ApplicationDefinitionArtifactName + :ivar uri: Required. The managed application definition artifact blob uri. + :vartype uri: str + :ivar type: Required. The managed application definition artifact type. Known values are: + "NotSpecified", "Template", "Custom". + :vartype type: str or + ~azure.mgmt.managedapplication.v2020_08_21_preview.models.ApplicationArtifactType + """ + + _validation = { + 'name': {'required': True}, + 'uri': {'required': True}, + 'type': {'required': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'uri': {'key': 'uri', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + } + + def __init__( + self, + *, + name: Union[str, "_models.ApplicationDefinitionArtifactName"], + uri: str, + type: Union[str, "_models.ApplicationArtifactType"], + **kwargs + ): + """ + :keyword name: Required. The managed application definition artifact name. Known values are: + "NotSpecified", "ApplicationResourceTemplate", "CreateUiDefinition", "MainTemplateParameters". + :paramtype name: str or + ~azure.mgmt.managedapplication.v2020_08_21_preview.models.ApplicationDefinitionArtifactName + :keyword uri: Required. The managed application definition artifact blob uri. + :paramtype uri: str + :keyword type: Required. The managed application definition artifact type. Known values are: + "NotSpecified", "Template", "Custom". + :paramtype type: str or + ~azure.mgmt.managedapplication.v2020_08_21_preview.models.ApplicationArtifactType + """ + super(ApplicationDefinitionArtifact, self).__init__(**kwargs) + self.name = name + self.uri = uri + self.type = type + + +class ApplicationDefinitionListResult(msrest.serialization.Model): + """List of managed application definitions. + + :ivar value: The array of managed application definitions. + :vartype value: + list[~azure.mgmt.managedapplication.v2020_08_21_preview.models.ApplicationDefinition] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[ApplicationDefinition]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["_models.ApplicationDefinition"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + """ + :keyword value: The array of managed application definitions. + :paramtype value: + list[~azure.mgmt.managedapplication.v2020_08_21_preview.models.ApplicationDefinition] + :keyword next_link: The URL to use for getting the next set of results. + :paramtype next_link: str + """ + super(ApplicationDefinitionListResult, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class ApplicationDefinitionPatchable(msrest.serialization.Model): + """Information about an application definition request. + + :ivar tags: A set of tags. Application definition tags. + :vartype tags: dict[str, str] + """ + + _attribute_map = { + 'tags': {'key': 'tags', 'type': '{str}'}, + } + + def __init__( + self, + *, + tags: Optional[Dict[str, str]] = None, + **kwargs + ): + """ + :keyword tags: A set of tags. Application definition tags. + :paramtype tags: dict[str, str] + """ + super(ApplicationDefinitionPatchable, self).__init__(**kwargs) + self.tags = tags + + +class ApplicationDeploymentPolicy(msrest.serialization.Model): + """Managed application deployment policy. + + All required parameters must be populated in order to send to Azure. + + :ivar deployment_mode: Required. The managed application deployment mode. Known values are: + "NotSpecified", "Incremental", "Complete". + :vartype deployment_mode: str or + ~azure.mgmt.managedapplication.v2020_08_21_preview.models.DeploymentMode + """ + + _validation = { + 'deployment_mode': {'required': True}, + } + + _attribute_map = { + 'deployment_mode': {'key': 'deploymentMode', 'type': 'str'}, + } + + def __init__( + self, + *, + deployment_mode: Union[str, "_models.DeploymentMode"], + **kwargs + ): + """ + :keyword deployment_mode: Required. The managed application deployment mode. Known values are: + "NotSpecified", "Incremental", "Complete". + :paramtype deployment_mode: str or + ~azure.mgmt.managedapplication.v2020_08_21_preview.models.DeploymentMode + """ + super(ApplicationDeploymentPolicy, self).__init__(**kwargs) + self.deployment_mode = deployment_mode + + +class ApplicationJitAccessPolicy(msrest.serialization.Model): + """Managed application Jit access policy. + + All required parameters must be populated in order to send to Azure. + + :ivar jit_access_enabled: Required. Whether the JIT access is enabled. + :vartype jit_access_enabled: bool + :ivar jit_approval_mode: JIT approval mode. Known values are: "NotSpecified", "AutoApprove", + "ManualApprove". + :vartype jit_approval_mode: str or + ~azure.mgmt.managedapplication.v2020_08_21_preview.models.JitApprovalMode + :ivar jit_approvers: The JIT approvers. + :vartype jit_approvers: + list[~azure.mgmt.managedapplication.v2020_08_21_preview.models.JitApproverDefinition] + :ivar maximum_jit_access_duration: The maximum duration JIT access is granted. This is an + ISO8601 time period value. + :vartype maximum_jit_access_duration: str + """ + + _validation = { + 'jit_access_enabled': {'required': True}, + } + + _attribute_map = { + 'jit_access_enabled': {'key': 'jitAccessEnabled', 'type': 'bool'}, + 'jit_approval_mode': {'key': 'jitApprovalMode', 'type': 'str'}, + 'jit_approvers': {'key': 'jitApprovers', 'type': '[JitApproverDefinition]'}, + 'maximum_jit_access_duration': {'key': 'maximumJitAccessDuration', 'type': 'str'}, + } + + def __init__( + self, + *, + jit_access_enabled: bool, + jit_approval_mode: Optional[Union[str, "_models.JitApprovalMode"]] = None, + jit_approvers: Optional[List["_models.JitApproverDefinition"]] = None, + maximum_jit_access_duration: Optional[str] = None, + **kwargs + ): + """ + :keyword jit_access_enabled: Required. Whether the JIT access is enabled. + :paramtype jit_access_enabled: bool + :keyword jit_approval_mode: JIT approval mode. Known values are: "NotSpecified", "AutoApprove", + "ManualApprove". + :paramtype jit_approval_mode: str or + ~azure.mgmt.managedapplication.v2020_08_21_preview.models.JitApprovalMode + :keyword jit_approvers: The JIT approvers. + :paramtype jit_approvers: + list[~azure.mgmt.managedapplication.v2020_08_21_preview.models.JitApproverDefinition] + :keyword maximum_jit_access_duration: The maximum duration JIT access is granted. This is an + ISO8601 time period value. + :paramtype maximum_jit_access_duration: str + """ + super(ApplicationJitAccessPolicy, self).__init__(**kwargs) + self.jit_access_enabled = jit_access_enabled + self.jit_approval_mode = jit_approval_mode + self.jit_approvers = jit_approvers + self.maximum_jit_access_duration = maximum_jit_access_duration + + +class ApplicationListResult(msrest.serialization.Model): + """List of managed applications. + + :ivar value: The array of managed applications. + :vartype value: list[~azure.mgmt.managedapplication.v2020_08_21_preview.models.Application] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Application]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["_models.Application"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + """ + :keyword value: The array of managed applications. + :paramtype value: list[~azure.mgmt.managedapplication.v2020_08_21_preview.models.Application] + :keyword next_link: The URL to use for getting the next set of results. + :paramtype next_link: str + """ + super(ApplicationListResult, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class ApplicationManagementPolicy(msrest.serialization.Model): + """Managed application management policy. + + :ivar mode: The managed application management mode. Known values are: "NotSpecified", + "Unmanaged", "Managed". + :vartype mode: str or + ~azure.mgmt.managedapplication.v2020_08_21_preview.models.ApplicationManagementMode + """ + + _attribute_map = { + 'mode': {'key': 'mode', 'type': 'str'}, + } + + def __init__( + self, + *, + mode: Optional[Union[str, "_models.ApplicationManagementMode"]] = None, + **kwargs + ): + """ + :keyword mode: The managed application management mode. Known values are: "NotSpecified", + "Unmanaged", "Managed". + :paramtype mode: str or + ~azure.mgmt.managedapplication.v2020_08_21_preview.models.ApplicationManagementMode + """ + super(ApplicationManagementPolicy, self).__init__(**kwargs) + self.mode = mode + + +class ApplicationNotificationEndpoint(msrest.serialization.Model): + """Managed application notification endpoint. + + All required parameters must be populated in order to send to Azure. + + :ivar uri: Required. The managed application notification endpoint uri. + :vartype uri: str + """ + + _validation = { + 'uri': {'required': True}, + } + + _attribute_map = { + 'uri': {'key': 'uri', 'type': 'str'}, + } + + def __init__( + self, + *, + uri: str, + **kwargs + ): + """ + :keyword uri: Required. The managed application notification endpoint uri. + :paramtype uri: str + """ + super(ApplicationNotificationEndpoint, self).__init__(**kwargs) + self.uri = uri + + +class ApplicationNotificationPolicy(msrest.serialization.Model): + """Managed application notification policy. + + All required parameters must be populated in order to send to Azure. + + :ivar notification_endpoints: Required. The managed application notification endpoint. + :vartype notification_endpoints: + list[~azure.mgmt.managedapplication.v2020_08_21_preview.models.ApplicationNotificationEndpoint] + """ + + _validation = { + 'notification_endpoints': {'required': True}, + } + + _attribute_map = { + 'notification_endpoints': {'key': 'notificationEndpoints', 'type': '[ApplicationNotificationEndpoint]'}, + } + + def __init__( + self, + *, + notification_endpoints: List["_models.ApplicationNotificationEndpoint"], + **kwargs + ): + """ + :keyword notification_endpoints: Required. The managed application notification endpoint. + :paramtype notification_endpoints: + list[~azure.mgmt.managedapplication.v2020_08_21_preview.models.ApplicationNotificationEndpoint] + """ + super(ApplicationNotificationPolicy, self).__init__(**kwargs) + self.notification_endpoints = notification_endpoints + + +class ApplicationPackageContact(msrest.serialization.Model): + """The application package contact information. + + All required parameters must be populated in order to send to Azure. + + :ivar contact_name: The contact name. + :vartype contact_name: str + :ivar email: Required. The contact email. + :vartype email: str + :ivar phone: Required. The contact phone number. + :vartype phone: str + """ + + _validation = { + 'email': {'required': True}, + 'phone': {'required': True}, + } + + _attribute_map = { + 'contact_name': {'key': 'contactName', 'type': 'str'}, + 'email': {'key': 'email', 'type': 'str'}, + 'phone': {'key': 'phone', 'type': 'str'}, + } + + def __init__( + self, + *, + email: str, + phone: str, + contact_name: Optional[str] = None, + **kwargs + ): + """ + :keyword contact_name: The contact name. + :paramtype contact_name: str + :keyword email: Required. The contact email. + :paramtype email: str + :keyword phone: Required. The contact phone number. + :paramtype phone: str + """ + super(ApplicationPackageContact, self).__init__(**kwargs) + self.contact_name = contact_name + self.email = email + self.phone = phone + + +class ApplicationPackageLockingPolicyDefinition(msrest.serialization.Model): + """Managed application locking policy. + + :ivar allowed_actions: The deny assignment excluded actions. + :vartype allowed_actions: list[str] + :ivar allowed_data_actions: The deny assignment excluded data actions. + :vartype allowed_data_actions: list[str] + """ + + _attribute_map = { + 'allowed_actions': {'key': 'allowedActions', 'type': '[str]'}, + 'allowed_data_actions': {'key': 'allowedDataActions', 'type': '[str]'}, + } + + def __init__( + self, + *, + allowed_actions: Optional[List[str]] = None, + allowed_data_actions: Optional[List[str]] = None, + **kwargs + ): + """ + :keyword allowed_actions: The deny assignment excluded actions. + :paramtype allowed_actions: list[str] + :keyword allowed_data_actions: The deny assignment excluded data actions. + :paramtype allowed_data_actions: list[str] + """ + super(ApplicationPackageLockingPolicyDefinition, self).__init__(**kwargs) + self.allowed_actions = allowed_actions + self.allowed_data_actions = allowed_data_actions + + +class ApplicationPackageSupportUrls(msrest.serialization.Model): + """The appliance package support URLs. + + :ivar public_azure: The public azure support URL. + :vartype public_azure: str + :ivar government_cloud: The government cloud support URL. + :vartype government_cloud: str + """ + + _attribute_map = { + 'public_azure': {'key': 'publicAzure', 'type': 'str'}, + 'government_cloud': {'key': 'governmentCloud', 'type': 'str'}, + } + + def __init__( + self, + *, + public_azure: Optional[str] = None, + government_cloud: Optional[str] = None, + **kwargs + ): + """ + :keyword public_azure: The public azure support URL. + :paramtype public_azure: str + :keyword government_cloud: The government cloud support URL. + :paramtype government_cloud: str + """ + super(ApplicationPackageSupportUrls, self).__init__(**kwargs) + self.public_azure = public_azure + self.government_cloud = government_cloud + + +class ApplicationPatchable(GenericResource): + """Information about managed application. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Resource ID. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar location: Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar managed_by: ID of the resource that manages this resource. + :vartype managed_by: str + :ivar sku: The SKU of the resource. + :vartype sku: ~azure.mgmt.managedapplication.v2020_08_21_preview.models.Sku + :ivar plan: The plan information. + :vartype plan: ~azure.mgmt.managedapplication.v2020_08_21_preview.models.PlanPatchable + :ivar kind: The kind of the managed application. Allowed values are MarketPlace and + ServiceCatalog. + :vartype kind: str + :ivar identity: The identity of the resource. + :vartype identity: ~azure.mgmt.managedapplication.v2020_08_21_preview.models.Identity + :ivar managed_resource_group_id: The managed resource group Id. + :vartype managed_resource_group_id: str + :ivar application_definition_id: The fully qualified path of managed application definition Id. + :vartype application_definition_id: str + :ivar parameters: Name and value pairs that define the managed application parameters. It can + be a JObject or a well formed JSON string. + :vartype parameters: any + :ivar outputs: Name and value pairs that define the managed application outputs. + :vartype outputs: any + :ivar provisioning_state: The managed application provisioning state. Known values are: + "NotSpecified", "Accepted", "Running", "Ready", "Creating", "Created", "Deleting", "Deleted", + "Canceled", "Failed", "Succeeded", "Updating". + :vartype provisioning_state: str or + ~azure.mgmt.managedapplication.v2020_08_21_preview.models.ProvisioningState + :ivar billing_details: The managed application billing details. + :vartype billing_details: + ~azure.mgmt.managedapplication.v2020_08_21_preview.models.ApplicationBillingDetailsDefinition + :ivar jit_access_policy: The managed application Jit access policy. + :vartype jit_access_policy: + ~azure.mgmt.managedapplication.v2020_08_21_preview.models.ApplicationJitAccessPolicy + :ivar publisher_tenant_id: The publisher tenant Id. + :vartype publisher_tenant_id: str + :ivar authorizations: The read-only authorizations property that is retrieved from the + application package. + :vartype authorizations: + list[~azure.mgmt.managedapplication.v2020_08_21_preview.models.ApplicationAuthorization] + :ivar management_mode: The managed application management mode. Known values are: + "NotSpecified", "Unmanaged", "Managed". + :vartype management_mode: str or + ~azure.mgmt.managedapplication.v2020_08_21_preview.models.ApplicationManagementMode + :ivar customer_support: The read-only customer support property that is retrieved from the + application package. + :vartype customer_support: + ~azure.mgmt.managedapplication.v2020_08_21_preview.models.ApplicationPackageContact + :ivar support_urls: The read-only support URLs property that is retrieved from the application + package. + :vartype support_urls: + ~azure.mgmt.managedapplication.v2020_08_21_preview.models.ApplicationPackageSupportUrls + :ivar artifacts: The collection of managed application artifacts. + :vartype artifacts: + list[~azure.mgmt.managedapplication.v2020_08_21_preview.models.ApplicationArtifact] + :ivar created_by: The client entity that created the JIT request. + :vartype created_by: + ~azure.mgmt.managedapplication.v2020_08_21_preview.models.ApplicationClientDetails + :ivar updated_by: The client entity that last updated the JIT request. + :vartype updated_by: + ~azure.mgmt.managedapplication.v2020_08_21_preview.models.ApplicationClientDetails + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'kind': {'pattern': r'^[-\w\._,\(\)]+$'}, + 'outputs': {'readonly': True}, + 'provisioning_state': {'readonly': True}, + 'billing_details': {'readonly': True}, + 'publisher_tenant_id': {'readonly': True}, + 'authorizations': {'readonly': True}, + 'management_mode': {'readonly': True}, + 'customer_support': {'readonly': True}, + 'support_urls': {'readonly': True}, + 'artifacts': {'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'}, + 'location': {'key': 'location', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + 'managed_by': {'key': 'managedBy', 'type': 'str'}, + 'sku': {'key': 'sku', 'type': 'Sku'}, + 'plan': {'key': 'plan', 'type': 'PlanPatchable'}, + 'kind': {'key': 'kind', 'type': 'str'}, + 'identity': {'key': 'identity', 'type': 'Identity'}, + 'managed_resource_group_id': {'key': 'properties.managedResourceGroupId', 'type': 'str'}, + 'application_definition_id': {'key': 'properties.applicationDefinitionId', 'type': 'str'}, + 'parameters': {'key': 'properties.parameters', 'type': 'object'}, + 'outputs': {'key': 'properties.outputs', 'type': 'object'}, + 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + 'billing_details': {'key': 'properties.billingDetails', 'type': 'ApplicationBillingDetailsDefinition'}, + 'jit_access_policy': {'key': 'properties.jitAccessPolicy', 'type': 'ApplicationJitAccessPolicy'}, + 'publisher_tenant_id': {'key': 'properties.publisherTenantId', 'type': 'str'}, + 'authorizations': {'key': 'properties.authorizations', 'type': '[ApplicationAuthorization]'}, + 'management_mode': {'key': 'properties.managementMode', 'type': 'str'}, + 'customer_support': {'key': 'properties.customerSupport', 'type': 'ApplicationPackageContact'}, + 'support_urls': {'key': 'properties.supportUrls', 'type': 'ApplicationPackageSupportUrls'}, + 'artifacts': {'key': 'properties.artifacts', 'type': '[ApplicationArtifact]'}, + 'created_by': {'key': 'properties.createdBy', 'type': 'ApplicationClientDetails'}, + 'updated_by': {'key': 'properties.updatedBy', 'type': 'ApplicationClientDetails'}, + } + + def __init__( + self, + *, + location: Optional[str] = None, + tags: Optional[Dict[str, str]] = None, + managed_by: Optional[str] = None, + sku: Optional["_models.Sku"] = None, + plan: Optional["_models.PlanPatchable"] = None, + kind: Optional[str] = None, + identity: Optional["_models.Identity"] = None, + managed_resource_group_id: Optional[str] = None, + application_definition_id: Optional[str] = None, + parameters: Optional[Any] = None, + jit_access_policy: Optional["_models.ApplicationJitAccessPolicy"] = None, + **kwargs + ): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword managed_by: ID of the resource that manages this resource. + :paramtype managed_by: str + :keyword sku: The SKU of the resource. + :paramtype sku: ~azure.mgmt.managedapplication.v2020_08_21_preview.models.Sku + :keyword plan: The plan information. + :paramtype plan: ~azure.mgmt.managedapplication.v2020_08_21_preview.models.PlanPatchable + :keyword kind: The kind of the managed application. Allowed values are MarketPlace and + ServiceCatalog. + :paramtype kind: str + :keyword identity: The identity of the resource. + :paramtype identity: ~azure.mgmt.managedapplication.v2020_08_21_preview.models.Identity + :keyword managed_resource_group_id: The managed resource group Id. + :paramtype managed_resource_group_id: str + :keyword application_definition_id: The fully qualified path of managed application definition + Id. + :paramtype application_definition_id: str + :keyword parameters: Name and value pairs that define the managed application parameters. It + can be a JObject or a well formed JSON string. + :paramtype parameters: any + :keyword jit_access_policy: The managed application Jit access policy. + :paramtype jit_access_policy: + ~azure.mgmt.managedapplication.v2020_08_21_preview.models.ApplicationJitAccessPolicy + """ + super(ApplicationPatchable, self).__init__(location=location, tags=tags, managed_by=managed_by, sku=sku, **kwargs) + self.plan = plan + self.kind = kind + self.identity = identity + self.managed_resource_group_id = managed_resource_group_id + self.application_definition_id = application_definition_id + self.parameters = parameters + self.outputs = None + self.provisioning_state = None + self.billing_details = None + self.jit_access_policy = jit_access_policy + self.publisher_tenant_id = None + self.authorizations = None + self.management_mode = None + self.customer_support = None + self.support_urls = None + self.artifacts = None + self.created_by = None + self.updated_by = None + + +class ApplicationPolicy(msrest.serialization.Model): + """Managed application policy. + + :ivar name: The policy name. + :vartype name: str + :ivar policy_definition_id: The policy definition Id. + :vartype policy_definition_id: str + :ivar parameters: The policy parameters. + :vartype parameters: str + """ + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'policy_definition_id': {'key': 'policyDefinitionId', 'type': 'str'}, + 'parameters': {'key': 'parameters', 'type': 'str'}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + policy_definition_id: Optional[str] = None, + parameters: Optional[str] = None, + **kwargs + ): + """ + :keyword name: The policy name. + :paramtype name: str + :keyword policy_definition_id: The policy definition Id. + :paramtype policy_definition_id: str + :keyword parameters: The policy parameters. + :paramtype parameters: str + """ + super(ApplicationPolicy, self).__init__(**kwargs) + self.name = name + self.policy_definition_id = policy_definition_id + self.parameters = parameters + + +class ApplicationPropertiesPatchable(msrest.serialization.Model): + """The managed application properties. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar managed_resource_group_id: The managed resource group Id. + :vartype managed_resource_group_id: str + :ivar application_definition_id: The fully qualified path of managed application definition Id. + :vartype application_definition_id: str + :ivar parameters: Name and value pairs that define the managed application parameters. It can + be a JObject or a well formed JSON string. + :vartype parameters: any + :ivar outputs: Name and value pairs that define the managed application outputs. + :vartype outputs: any + :ivar provisioning_state: The managed application provisioning state. Known values are: + "NotSpecified", "Accepted", "Running", "Ready", "Creating", "Created", "Deleting", "Deleted", + "Canceled", "Failed", "Succeeded", "Updating". + :vartype provisioning_state: str or + ~azure.mgmt.managedapplication.v2020_08_21_preview.models.ProvisioningState + """ + + _validation = { + 'outputs': {'readonly': True}, + 'provisioning_state': {'readonly': True}, + } + + _attribute_map = { + 'managed_resource_group_id': {'key': 'managedResourceGroupId', 'type': 'str'}, + 'application_definition_id': {'key': 'applicationDefinitionId', 'type': 'str'}, + 'parameters': {'key': 'parameters', 'type': 'object'}, + 'outputs': {'key': 'outputs', 'type': 'object'}, + 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, + } + + def __init__( + self, + *, + managed_resource_group_id: Optional[str] = None, + application_definition_id: Optional[str] = None, + parameters: Optional[Any] = None, + **kwargs + ): + """ + :keyword managed_resource_group_id: The managed resource group Id. + :paramtype managed_resource_group_id: str + :keyword application_definition_id: The fully qualified path of managed application definition + Id. + :paramtype application_definition_id: str + :keyword parameters: Name and value pairs that define the managed application parameters. It + can be a JObject or a well formed JSON string. + :paramtype parameters: any + """ + super(ApplicationPropertiesPatchable, self).__init__(**kwargs) + self.managed_resource_group_id = managed_resource_group_id + self.application_definition_id = application_definition_id + self.parameters = parameters + self.outputs = None + self.provisioning_state = None + + +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.managedapplication.v2020_08_21_preview.models.ErrorDetail] + :ivar additional_info: The error additional info. + :vartype additional_info: + list[~azure.mgmt.managedapplication.v2020_08_21_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.). + + :ivar error: The error object. + :vartype error: ~azure.mgmt.managedapplication.v2020_08_21_preview.models.ErrorDetail + """ + + _attribute_map = { + 'error': {'key': 'error', 'type': 'ErrorDetail'}, + } + + def __init__( + self, + *, + error: Optional["_models.ErrorDetail"] = None, + **kwargs + ): + """ + :keyword error: The error object. + :paramtype error: ~azure.mgmt.managedapplication.v2020_08_21_preview.models.ErrorDetail + """ + super(ErrorResponse, self).__init__(**kwargs) + self.error = error + + +class Identity(msrest.serialization.Model): + """Identity for the resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar principal_id: The principal ID of resource identity. + :vartype principal_id: str + :ivar tenant_id: The tenant ID of resource. + :vartype tenant_id: str + :ivar type: The identity type. Known values are: "SystemAssigned", "UserAssigned", + "SystemAssigned, UserAssigned", "None". + :vartype type: str or + ~azure.mgmt.managedapplication.v2020_08_21_preview.models.ResourceIdentityType + :ivar user_assigned_identities: The list of user identities associated with the resource. The + user identity dictionary key references will be resource ids in the form: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'. + :vartype user_assigned_identities: dict[str, + ~azure.mgmt.managedapplication.v2020_08_21_preview.models.UserAssignedResourceIdentity] + """ + + _validation = { + 'principal_id': {'readonly': True}, + 'tenant_id': {'readonly': True}, + } + + _attribute_map = { + 'principal_id': {'key': 'principalId', 'type': 'str'}, + 'tenant_id': {'key': 'tenantId', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'user_assigned_identities': {'key': 'userAssignedIdentities', 'type': '{UserAssignedResourceIdentity}'}, + } + + def __init__( + self, + *, + type: Optional[Union[str, "_models.ResourceIdentityType"]] = None, + user_assigned_identities: Optional[Dict[str, "_models.UserAssignedResourceIdentity"]] = None, + **kwargs + ): + """ + :keyword type: The identity type. Known values are: "SystemAssigned", "UserAssigned", + "SystemAssigned, UserAssigned", "None". + :paramtype type: str or + ~azure.mgmt.managedapplication.v2020_08_21_preview.models.ResourceIdentityType + :keyword user_assigned_identities: The list of user identities associated with the resource. + The user identity dictionary key references will be resource ids in the form: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'. + :paramtype user_assigned_identities: dict[str, + ~azure.mgmt.managedapplication.v2020_08_21_preview.models.UserAssignedResourceIdentity] + """ + super(Identity, self).__init__(**kwargs) + self.principal_id = None + self.tenant_id = None + self.type = type + self.user_assigned_identities = user_assigned_identities + + +class JitApproverDefinition(msrest.serialization.Model): + """JIT approver definition. + + All required parameters must be populated in order to send to Azure. + + :ivar id: Required. The approver service principal Id. + :vartype id: str + :ivar type: The approver type. Known values are: "user", "group". + :vartype type: str or ~azure.mgmt.managedapplication.v2020_08_21_preview.models.JitApproverType + :ivar display_name: The approver display name. + :vartype display_name: str + """ + + _validation = { + 'id': {'required': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'display_name': {'key': 'displayName', 'type': 'str'}, + } + + def __init__( + self, + *, + id: str, + type: Optional[Union[str, "_models.JitApproverType"]] = None, + display_name: Optional[str] = None, + **kwargs + ): + """ + :keyword id: Required. The approver service principal Id. + :paramtype id: str + :keyword type: The approver type. Known values are: "user", "group". + :paramtype type: str or + ~azure.mgmt.managedapplication.v2020_08_21_preview.models.JitApproverType + :keyword display_name: The approver display name. + :paramtype display_name: str + """ + super(JitApproverDefinition, self).__init__(**kwargs) + self.id = id + self.type = type + self.display_name = display_name + + +class JitAuthorizationPolicies(msrest.serialization.Model): + """The JIT authorization policies. + + All required parameters must be populated in order to send to Azure. + + :ivar principal_id: Required. The the principal id that will be granted JIT access. + :vartype principal_id: str + :ivar role_definition_id: Required. The role definition id that will be granted to the + Principal. + :vartype role_definition_id: str + """ + + _validation = { + 'principal_id': {'required': True}, + 'role_definition_id': {'required': True}, + } + + _attribute_map = { + 'principal_id': {'key': 'principalId', 'type': 'str'}, + 'role_definition_id': {'key': 'roleDefinitionId', 'type': 'str'}, + } + + def __init__( + self, + *, + principal_id: str, + role_definition_id: str, + **kwargs + ): + """ + :keyword principal_id: Required. The the principal id that will be granted JIT access. + :paramtype principal_id: str + :keyword role_definition_id: Required. The role definition id that will be granted to the + Principal. + :paramtype role_definition_id: str + """ + super(JitAuthorizationPolicies, self).__init__(**kwargs) + self.principal_id = principal_id + self.role_definition_id = role_definition_id + + +class JitRequestDefinition(Resource): + """Information about JIT request definition. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Resource ID. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar location: Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar application_resource_id: The parent application id. + :vartype application_resource_id: str + :ivar publisher_tenant_id: The publisher tenant id. + :vartype publisher_tenant_id: str + :ivar jit_authorization_policies: The JIT authorization policies. + :vartype jit_authorization_policies: + list[~azure.mgmt.managedapplication.v2020_08_21_preview.models.JitAuthorizationPolicies] + :ivar jit_scheduling_policy: The JIT request properties. + :vartype jit_scheduling_policy: + ~azure.mgmt.managedapplication.v2020_08_21_preview.models.JitSchedulingPolicy + :ivar provisioning_state: The JIT request provisioning state. Known values are: "NotSpecified", + "Accepted", "Running", "Ready", "Creating", "Created", "Deleting", "Deleted", "Canceled", + "Failed", "Succeeded", "Updating". + :vartype provisioning_state: str or + ~azure.mgmt.managedapplication.v2020_08_21_preview.models.ProvisioningState + :ivar jit_request_state: The JIT request state. Known values are: "NotSpecified", "Pending", + "Approved", "Denied", "Failed", "Canceled", "Expired", "Timeout". + :vartype jit_request_state: str or + ~azure.mgmt.managedapplication.v2020_08_21_preview.models.JitRequestState + :ivar created_by: The client entity that created the JIT request. + :vartype created_by: + ~azure.mgmt.managedapplication.v2020_08_21_preview.models.ApplicationClientDetails + :ivar updated_by: The client entity that last updated the JIT request. + :vartype updated_by: + ~azure.mgmt.managedapplication.v2020_08_21_preview.models.ApplicationClientDetails + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'publisher_tenant_id': {'readonly': True}, + 'provisioning_state': {'readonly': True}, + 'jit_request_state': {'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'}, + 'location': {'key': 'location', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + 'application_resource_id': {'key': 'properties.applicationResourceId', 'type': 'str'}, + 'publisher_tenant_id': {'key': 'properties.publisherTenantId', 'type': 'str'}, + 'jit_authorization_policies': {'key': 'properties.jitAuthorizationPolicies', 'type': '[JitAuthorizationPolicies]'}, + 'jit_scheduling_policy': {'key': 'properties.jitSchedulingPolicy', 'type': 'JitSchedulingPolicy'}, + 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + 'jit_request_state': {'key': 'properties.jitRequestState', 'type': 'str'}, + 'created_by': {'key': 'properties.createdBy', 'type': 'ApplicationClientDetails'}, + 'updated_by': {'key': 'properties.updatedBy', 'type': 'ApplicationClientDetails'}, + } + + def __init__( + self, + *, + location: Optional[str] = None, + tags: Optional[Dict[str, str]] = None, + application_resource_id: Optional[str] = None, + jit_authorization_policies: Optional[List["_models.JitAuthorizationPolicies"]] = None, + jit_scheduling_policy: Optional["_models.JitSchedulingPolicy"] = None, + **kwargs + ): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword application_resource_id: The parent application id. + :paramtype application_resource_id: str + :keyword jit_authorization_policies: The JIT authorization policies. + :paramtype jit_authorization_policies: + list[~azure.mgmt.managedapplication.v2020_08_21_preview.models.JitAuthorizationPolicies] + :keyword jit_scheduling_policy: The JIT request properties. + :paramtype jit_scheduling_policy: + ~azure.mgmt.managedapplication.v2020_08_21_preview.models.JitSchedulingPolicy + """ + super(JitRequestDefinition, self).__init__(location=location, tags=tags, **kwargs) + self.application_resource_id = application_resource_id + self.publisher_tenant_id = None + self.jit_authorization_policies = jit_authorization_policies + self.jit_scheduling_policy = jit_scheduling_policy + self.provisioning_state = None + self.jit_request_state = None + self.created_by = None + self.updated_by = None + + +class JitRequestDefinitionListResult(msrest.serialization.Model): + """List of JIT requests. + + :ivar value: The array of Jit request definition. + :vartype value: + list[~azure.mgmt.managedapplication.v2020_08_21_preview.models.JitRequestDefinition] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[JitRequestDefinition]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["_models.JitRequestDefinition"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + """ + :keyword value: The array of Jit request definition. + :paramtype value: + list[~azure.mgmt.managedapplication.v2020_08_21_preview.models.JitRequestDefinition] + :keyword next_link: The URL to use for getting the next set of results. + :paramtype next_link: str + """ + super(JitRequestDefinitionListResult, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class JitRequestMetadata(msrest.serialization.Model): + """The JIT request metadata. + + :ivar origin_request_id: The origin request id. + :vartype origin_request_id: str + :ivar requestor_id: The requestor id. + :vartype requestor_id: str + :ivar tenant_display_name: The publisher's tenant name. + :vartype tenant_display_name: str + :ivar subject_display_name: The subject display name. + :vartype subject_display_name: str + """ + + _attribute_map = { + 'origin_request_id': {'key': 'originRequestId', 'type': 'str'}, + 'requestor_id': {'key': 'requestorId', 'type': 'str'}, + 'tenant_display_name': {'key': 'tenantDisplayName', 'type': 'str'}, + 'subject_display_name': {'key': 'subjectDisplayName', 'type': 'str'}, + } + + def __init__( + self, + *, + origin_request_id: Optional[str] = None, + requestor_id: Optional[str] = None, + tenant_display_name: Optional[str] = None, + subject_display_name: Optional[str] = None, + **kwargs + ): + """ + :keyword origin_request_id: The origin request id. + :paramtype origin_request_id: str + :keyword requestor_id: The requestor id. + :paramtype requestor_id: str + :keyword tenant_display_name: The publisher's tenant name. + :paramtype tenant_display_name: str + :keyword subject_display_name: The subject display name. + :paramtype subject_display_name: str + """ + super(JitRequestMetadata, self).__init__(**kwargs) + self.origin_request_id = origin_request_id + self.requestor_id = requestor_id + self.tenant_display_name = tenant_display_name + self.subject_display_name = subject_display_name + + +class JitRequestPatchable(msrest.serialization.Model): + """Information about JIT request. + + :ivar tags: A set of tags. Jit request tags. + :vartype tags: dict[str, str] + """ + + _attribute_map = { + 'tags': {'key': 'tags', 'type': '{str}'}, + } + + def __init__( + self, + *, + tags: Optional[Dict[str, str]] = None, + **kwargs + ): + """ + :keyword tags: A set of tags. Jit request tags. + :paramtype tags: dict[str, str] + """ + super(JitRequestPatchable, self).__init__(**kwargs) + self.tags = tags + + +class JitSchedulingPolicy(msrest.serialization.Model): + """The JIT scheduling policies. + + All required parameters must be populated in order to send to Azure. + + :ivar type: Required. The type of JIT schedule. Known values are: "NotSpecified", "Once", + "Recurring". + :vartype type: str or + ~azure.mgmt.managedapplication.v2020_08_21_preview.models.JitSchedulingType + :ivar duration: Required. The required duration of the JIT request. + :vartype duration: ~datetime.timedelta + :ivar start_time: Required. The start time of the request. + :vartype start_time: ~datetime.datetime + """ + + _validation = { + 'type': {'required': True}, + 'duration': {'required': True}, + 'start_time': {'required': True}, + } + + _attribute_map = { + 'type': {'key': 'type', 'type': 'str'}, + 'duration': {'key': 'duration', 'type': 'duration'}, + 'start_time': {'key': 'startTime', 'type': 'iso-8601'}, + } + + def __init__( + self, + *, + type: Union[str, "_models.JitSchedulingType"], + duration: datetime.timedelta, + start_time: datetime.datetime, + **kwargs + ): + """ + :keyword type: Required. The type of JIT schedule. Known values are: "NotSpecified", "Once", + "Recurring". + :paramtype type: str or + ~azure.mgmt.managedapplication.v2020_08_21_preview.models.JitSchedulingType + :keyword duration: Required. The required duration of the JIT request. + :paramtype duration: ~datetime.timedelta + :keyword start_time: Required. The start time of the request. + :paramtype start_time: ~datetime.datetime + """ + super(JitSchedulingPolicy, self).__init__(**kwargs) + self.type = type + self.duration = duration + self.start_time = start_time + + +class ListTokenRequest(msrest.serialization.Model): + """List token request body. + + :ivar authorization_audience: The authorization audience. + :vartype authorization_audience: str + :ivar user_assigned_identities: The user assigned identities. + :vartype user_assigned_identities: list[str] + """ + + _attribute_map = { + 'authorization_audience': {'key': 'authorizationAudience', 'type': 'str'}, + 'user_assigned_identities': {'key': 'userAssignedIdentities', 'type': '[str]'}, + } + + def __init__( + self, + *, + authorization_audience: Optional[str] = None, + user_assigned_identities: Optional[List[str]] = None, + **kwargs + ): + """ + :keyword authorization_audience: The authorization audience. + :paramtype authorization_audience: str + :keyword user_assigned_identities: The user assigned identities. + :paramtype user_assigned_identities: list[str] + """ + super(ListTokenRequest, self).__init__(**kwargs) + self.authorization_audience = authorization_audience + self.user_assigned_identities = user_assigned_identities + + +class ManagedIdentityToken(msrest.serialization.Model): + """The managed identity token for the managed app resource. + + :ivar access_token: The requested access token. + :vartype access_token: str + :ivar expires_in: The number of seconds the access token will be valid. + :vartype expires_in: str + :ivar expires_on: The timespan when the access token expires. This is represented as the number + of seconds from epoch. + :vartype expires_on: str + :ivar not_before: The timespan when the access token takes effect. This is represented as the + number of seconds from epoch. + :vartype not_before: str + :ivar authorization_audience: The aud (audience) the access token was request for. This is the + same as what was provided in the listTokens request. + :vartype authorization_audience: str + :ivar resource_id: The Azure resource ID for the issued token. This is either the managed + application ID or the user-assigned identity ID. + :vartype resource_id: str + :ivar token_type: The type of the token. + :vartype token_type: str + """ + + _attribute_map = { + 'access_token': {'key': 'accessToken', 'type': 'str'}, + 'expires_in': {'key': 'expiresIn', 'type': 'str'}, + 'expires_on': {'key': 'expiresOn', 'type': 'str'}, + 'not_before': {'key': 'notBefore', 'type': 'str'}, + 'authorization_audience': {'key': 'authorizationAudience', 'type': 'str'}, + 'resource_id': {'key': 'resourceId', 'type': 'str'}, + 'token_type': {'key': 'tokenType', 'type': 'str'}, + } + + def __init__( + self, + *, + access_token: Optional[str] = None, + expires_in: Optional[str] = None, + expires_on: Optional[str] = None, + not_before: Optional[str] = None, + authorization_audience: Optional[str] = None, + resource_id: Optional[str] = None, + token_type: Optional[str] = None, + **kwargs + ): + """ + :keyword access_token: The requested access token. + :paramtype access_token: str + :keyword expires_in: The number of seconds the access token will be valid. + :paramtype expires_in: str + :keyword expires_on: The timespan when the access token expires. This is represented as the + number of seconds from epoch. + :paramtype expires_on: str + :keyword not_before: The timespan when the access token takes effect. This is represented as + the number of seconds from epoch. + :paramtype not_before: str + :keyword authorization_audience: The aud (audience) the access token was request for. This is + the same as what was provided in the listTokens request. + :paramtype authorization_audience: str + :keyword resource_id: The Azure resource ID for the issued token. This is either the managed + application ID or the user-assigned identity ID. + :paramtype resource_id: str + :keyword token_type: The type of the token. + :paramtype token_type: str + """ + super(ManagedIdentityToken, self).__init__(**kwargs) + self.access_token = access_token + self.expires_in = expires_in + self.expires_on = expires_on + self.not_before = not_before + self.authorization_audience = authorization_audience + self.resource_id = resource_id + self.token_type = token_type + + +class ManagedIdentityTokenResult(msrest.serialization.Model): + """The array of managed identity tokens. + + :ivar value: The array of managed identity tokens. + :vartype value: + list[~azure.mgmt.managedapplication.v2020_08_21_preview.models.ManagedIdentityToken] + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[ManagedIdentityToken]'}, + } + + def __init__( + self, + *, + value: Optional[List["_models.ManagedIdentityToken"]] = None, + **kwargs + ): + """ + :keyword value: The array of managed identity tokens. + :paramtype value: + list[~azure.mgmt.managedapplication.v2020_08_21_preview.models.ManagedIdentityToken] + """ + super(ManagedIdentityTokenResult, self).__init__(**kwargs) + self.value = value + + +class Operation(msrest.serialization.Model): + """Details of a REST API operation, returned from the Resource Provider Operations API. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name: The name of the operation, as per Resource-Based Access Control (RBAC). Examples: + "Microsoft.Compute/virtualMachines/write", "Microsoft.Compute/virtualMachines/capture/action". + :vartype name: str + :ivar is_data_action: Whether the operation applies to data-plane. This is "true" for + data-plane operations and "false" for ARM/control-plane operations. + :vartype is_data_action: bool + :ivar display: Localized display information for this particular operation. + :vartype display: ~azure.mgmt.managedapplication.v2020_08_21_preview.models.OperationDisplay + :ivar origin: The intended executor of the operation; as in Resource Based Access Control + (RBAC) and audit logs UX. Default value is "user,system". Known values are: "user", "system", + "user,system". + :vartype origin: str or ~azure.mgmt.managedapplication.v2020_08_21_preview.models.Origin + :ivar action_type: Enum. Indicates the action type. "Internal" refers to actions that are for + internal only APIs. Known values are: "Internal". + :vartype action_type: str or + ~azure.mgmt.managedapplication.v2020_08_21_preview.models.ActionType + """ + + _validation = { + 'name': {'readonly': True}, + 'is_data_action': {'readonly': True}, + 'origin': {'readonly': True}, + 'action_type': {'readonly': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'is_data_action': {'key': 'isDataAction', 'type': 'bool'}, + 'display': {'key': 'display', 'type': 'OperationDisplay'}, + 'origin': {'key': 'origin', 'type': 'str'}, + 'action_type': {'key': 'actionType', 'type': 'str'}, + } + + def __init__( + self, + *, + display: Optional["_models.OperationDisplay"] = None, + **kwargs + ): + """ + :keyword display: Localized display information for this particular operation. + :paramtype display: ~azure.mgmt.managedapplication.v2020_08_21_preview.models.OperationDisplay + """ + super(Operation, self).__init__(**kwargs) + self.name = None + self.is_data_action = None + self.display = display + self.origin = None + self.action_type = None + + +class OperationAutoGenerated(msrest.serialization.Model): + """Microsoft.Solutions operation. + + :ivar name: Operation name: {provider}/{resource}/{operation}. + :vartype name: str + :ivar is_data_action: Indicates whether the operation is a data action. + :vartype is_data_action: bool + :ivar display: The object that represents the operation. + :vartype display: + ~azure.mgmt.managedapplication.v2020_08_21_preview.models.OperationDisplayAutoGenerated + """ + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'is_data_action': {'key': 'isDataAction', 'type': 'bool'}, + 'display': {'key': 'display', 'type': 'OperationDisplayAutoGenerated'}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + is_data_action: Optional[bool] = None, + display: Optional["_models.OperationDisplayAutoGenerated"] = None, + **kwargs + ): + """ + :keyword name: Operation name: {provider}/{resource}/{operation}. + :paramtype name: str + :keyword is_data_action: Indicates whether the operation is a data action. + :paramtype is_data_action: bool + :keyword display: The object that represents the operation. + :paramtype display: + ~azure.mgmt.managedapplication.v2020_08_21_preview.models.OperationDisplayAutoGenerated + """ + super(OperationAutoGenerated, self).__init__(**kwargs) + self.name = name + self.is_data_action = is_data_action + self.display = display + + +class OperationDisplay(msrest.serialization.Model): + """Localized display information for this particular operation. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar provider: The localized friendly form of the resource provider name, e.g. "Microsoft + Monitoring Insights" or "Microsoft Compute". + :vartype provider: str + :ivar resource: The localized friendly name of the resource type related to this operation. + E.g. "Virtual Machines" or "Job Schedule Collections". + :vartype resource: str + :ivar operation: The concise, localized friendly name for the operation; suitable for + dropdowns. E.g. "Create or Update Virtual Machine", "Restart Virtual Machine". + :vartype operation: str + :ivar description: The short, localized friendly description of the operation; suitable for + tool tips and detailed views. + :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 OperationDisplayAutoGenerated(msrest.serialization.Model): + """The object that represents the operation. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar provider: Service provider: Microsoft.Solutions. + :vartype provider: str + :ivar resource: Resource on which the operation is performed: Application, JitRequest, etc. + :vartype resource: str + :ivar operation: Operation type: Read, write, delete, etc. + :vartype operation: str + :ivar description: Localized friendly description for the operation. + :vartype description: str + """ + + _validation = { + '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, + *, + provider: Optional[str] = None, + resource: Optional[str] = None, + operation: Optional[str] = None, + **kwargs + ): + """ + :keyword provider: Service provider: Microsoft.Solutions. + :paramtype provider: str + :keyword resource: Resource on which the operation is performed: Application, JitRequest, etc. + :paramtype resource: str + :keyword operation: Operation type: Read, write, delete, etc. + :paramtype operation: str + """ + super(OperationDisplayAutoGenerated, self).__init__(**kwargs) + self.provider = provider + self.resource = resource + self.operation = operation + self.description = None + + +class OperationListResult(msrest.serialization.Model): + """A list of REST API operations supported by an Azure Resource Provider. It contains an URL link to get the next set of results. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: List of operations supported by the resource provider. + :vartype value: list[~azure.mgmt.managedapplication.v2020_08_21_preview.models.Operation] + :ivar next_link: URL to get the next set of operation list results (if there are any). + :vartype next_link: str + """ + + _validation = { + 'value': {'readonly': True}, + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Operation]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(OperationListResult, self).__init__(**kwargs) + self.value = None + self.next_link = None + + +class OperationListResultAutoGenerated(msrest.serialization.Model): + """Result of the request to list Microsoft.Solutions operations. It contains a list of operations and a URL link to get the next set of results. + + :ivar value: List of Microsoft.Solutions operations. + :vartype value: + list[~azure.mgmt.managedapplication.v2020_08_21_preview.models.OperationAutoGenerated] + :ivar next_link: URL to get the next set of operation list results if there are any. + :vartype next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[OperationAutoGenerated]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["_models.OperationAutoGenerated"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + """ + :keyword value: List of Microsoft.Solutions operations. + :paramtype value: + list[~azure.mgmt.managedapplication.v2020_08_21_preview.models.OperationAutoGenerated] + :keyword next_link: URL to get the next set of operation list results if there are any. + :paramtype next_link: str + """ + super(OperationListResultAutoGenerated, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class Plan(msrest.serialization.Model): + """Plan for the managed application. + + All required parameters must be populated in order to send to Azure. + + :ivar name: Required. The plan name. + :vartype name: str + :ivar publisher: Required. The publisher ID. + :vartype publisher: str + :ivar product: Required. The product code. + :vartype product: str + :ivar promotion_code: The promotion code. + :vartype promotion_code: str + :ivar version: Required. The plan's version. + :vartype version: str + """ + + _validation = { + 'name': {'required': True}, + 'publisher': {'required': True}, + 'product': {'required': True}, + 'version': {'required': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'publisher': {'key': 'publisher', 'type': 'str'}, + 'product': {'key': 'product', 'type': 'str'}, + 'promotion_code': {'key': 'promotionCode', 'type': 'str'}, + 'version': {'key': 'version', 'type': 'str'}, + } + + def __init__( + self, + *, + name: str, + publisher: str, + product: str, + version: str, + promotion_code: Optional[str] = None, + **kwargs + ): + """ + :keyword name: Required. The plan name. + :paramtype name: str + :keyword publisher: Required. The publisher ID. + :paramtype publisher: str + :keyword product: Required. The product code. + :paramtype product: str + :keyword promotion_code: The promotion code. + :paramtype promotion_code: str + :keyword version: Required. The plan's version. + :paramtype version: str + """ + super(Plan, self).__init__(**kwargs) + self.name = name + self.publisher = publisher + self.product = product + self.promotion_code = promotion_code + self.version = version + + +class PlanPatchable(msrest.serialization.Model): + """Plan for the managed application. + + :ivar name: The plan name. + :vartype name: str + :ivar publisher: The publisher ID. + :vartype publisher: str + :ivar product: The product code. + :vartype product: str + :ivar promotion_code: The promotion code. + :vartype promotion_code: str + :ivar version: The plan's version. + :vartype version: str + """ + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'publisher': {'key': 'publisher', 'type': 'str'}, + 'product': {'key': 'product', 'type': 'str'}, + 'promotion_code': {'key': 'promotionCode', 'type': 'str'}, + 'version': {'key': 'version', 'type': 'str'}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + publisher: Optional[str] = None, + product: Optional[str] = None, + promotion_code: Optional[str] = None, + version: Optional[str] = None, + **kwargs + ): + """ + :keyword name: The plan name. + :paramtype name: str + :keyword publisher: The publisher ID. + :paramtype publisher: str + :keyword product: The product code. + :paramtype product: str + :keyword promotion_code: The promotion code. + :paramtype promotion_code: str + :keyword version: The plan's version. + :paramtype version: str + """ + super(PlanPatchable, self).__init__(**kwargs) + self.name = name + self.publisher = publisher + self.product = product + self.promotion_code = promotion_code + self.version = version + + +class Sku(msrest.serialization.Model): + """SKU for the resource. + + All required parameters must be populated in order to send to Azure. + + :ivar name: Required. The SKU name. + :vartype name: str + :ivar tier: The SKU tier. + :vartype tier: str + :ivar size: The SKU size. + :vartype size: str + :ivar family: The SKU family. + :vartype family: str + :ivar model: The SKU model. + :vartype model: str + :ivar capacity: The SKU capacity. + :vartype capacity: int + """ + + _validation = { + 'name': {'required': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'tier': {'key': 'tier', 'type': 'str'}, + 'size': {'key': 'size', 'type': 'str'}, + 'family': {'key': 'family', 'type': 'str'}, + 'model': {'key': 'model', 'type': 'str'}, + 'capacity': {'key': 'capacity', 'type': 'int'}, + } + + def __init__( + self, + *, + name: str, + tier: Optional[str] = None, + size: Optional[str] = None, + family: Optional[str] = None, + model: Optional[str] = None, + capacity: Optional[int] = None, + **kwargs + ): + """ + :keyword name: Required. The SKU name. + :paramtype name: str + :keyword tier: The SKU tier. + :paramtype tier: str + :keyword size: The SKU size. + :paramtype size: str + :keyword family: The SKU family. + :paramtype family: str + :keyword model: The SKU model. + :paramtype model: str + :keyword capacity: The SKU capacity. + :paramtype capacity: int + """ + super(Sku, self).__init__(**kwargs) + self.name = name + self.tier = tier + self.size = size + self.family = family + self.model = model + self.capacity = capacity + + +class UpdateAccessDefinition(msrest.serialization.Model): + """Update access request definition. + + All required parameters must be populated in order to send to Azure. + + :ivar approver: The approver name. + :vartype approver: str + :ivar metadata: Required. The JIT request metadata. + :vartype metadata: ~azure.mgmt.managedapplication.v2020_08_21_preview.models.JitRequestMetadata + :ivar status: Required. The JIT status. Known values are: "NotSpecified", "Elevate", "Remove". + :vartype status: str or ~azure.mgmt.managedapplication.v2020_08_21_preview.models.Status + :ivar sub_status: Required. The JIT status. Known values are: "NotSpecified", "Approved", + "Denied", "Failed", "Expired", "Timeout". + :vartype sub_status: str or ~azure.mgmt.managedapplication.v2020_08_21_preview.models.Substatus + """ + + _validation = { + 'metadata': {'required': True}, + 'status': {'required': True}, + 'sub_status': {'required': True}, + } + + _attribute_map = { + 'approver': {'key': 'approver', 'type': 'str'}, + 'metadata': {'key': 'metadata', 'type': 'JitRequestMetadata'}, + 'status': {'key': 'status', 'type': 'str'}, + 'sub_status': {'key': 'subStatus', 'type': 'str'}, + } + + def __init__( + self, + *, + metadata: "_models.JitRequestMetadata", + status: Union[str, "_models.Status"], + sub_status: Union[str, "_models.Substatus"], + approver: Optional[str] = None, + **kwargs + ): + """ + :keyword approver: The approver name. + :paramtype approver: str + :keyword metadata: Required. The JIT request metadata. + :paramtype metadata: + ~azure.mgmt.managedapplication.v2020_08_21_preview.models.JitRequestMetadata + :keyword status: Required. The JIT status. Known values are: "NotSpecified", "Elevate", + "Remove". + :paramtype status: str or ~azure.mgmt.managedapplication.v2020_08_21_preview.models.Status + :keyword sub_status: Required. The JIT status. Known values are: "NotSpecified", "Approved", + "Denied", "Failed", "Expired", "Timeout". + :paramtype sub_status: str or + ~azure.mgmt.managedapplication.v2020_08_21_preview.models.Substatus + """ + super(UpdateAccessDefinition, self).__init__(**kwargs) + self.approver = approver + self.metadata = metadata + self.status = status + self.sub_status = sub_status + + +class UserAssignedResourceIdentity(msrest.serialization.Model): + """Represents the user assigned identity that is contained within the UserAssignedIdentities dictionary on ResourceIdentity. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar principal_id: The principal id of user assigned identity. + :vartype principal_id: str + :ivar tenant_id: The tenant id of user assigned identity. + :vartype tenant_id: str + """ + + _validation = { + 'principal_id': {'readonly': True}, + 'tenant_id': {'readonly': True}, + } + + _attribute_map = { + 'principal_id': {'key': 'principalId', 'type': 'str'}, + 'tenant_id': {'key': 'tenantId', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(UserAssignedResourceIdentity, self).__init__(**kwargs) + self.principal_id = None + self.tenant_id = None diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2020_08_21_preview/models/_patch.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2020_08_21_preview/models/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2020_08_21_preview/models/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2020_08_21_preview/operations/__init__.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2020_08_21_preview/operations/__init__.py new file mode 100644 index 000000000000..b93ecbbe65e2 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2020_08_21_preview/operations/__init__.py @@ -0,0 +1,24 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._application_client_operations import ApplicationClientOperationsMixin +from ._applications_operations import ApplicationsOperations +from ._application_definitions_operations import ApplicationDefinitionsOperations +from ._jit_requests_operations import JitRequestsOperations + +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk +__all__ = [ + 'ApplicationClientOperationsMixin', + 'ApplicationsOperations', + 'ApplicationDefinitionsOperations', + 'JitRequestsOperations', +] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2020_08_21_preview/operations/_application_client_operations.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2020_08_21_preview/operations/_application_client_operations.py new file mode 100644 index 000000000000..e3a6771b8f89 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2020_08_21_preview/operations/_application_client_operations.py @@ -0,0 +1,134 @@ +# 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.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._vendor import MixinABC, _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_operations_request( + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-21-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.Solutions/operations") + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + +class ApplicationClientOperationsMixin(MixinABC): + + @distributed_trace + def list_operations( + self, + **kwargs: Any + ) -> Iterable[_models.OperationListResult]: + """Lists all of the available Microsoft.Solutions REST API operations. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either OperationListResult or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.managedapplication.v2020_08_21_preview.models.OperationListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-21-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', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_operations_request( + api_version=api_version, + template_url=self.list_operations.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_operations_request( + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list_operations.metadata = {'url': "/providers/Microsoft.Solutions/operations"} # type: ignore diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2020_08_21_preview/operations/_application_definitions_operations.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2020_08_21_preview/operations/_application_definitions_operations.py new file mode 100644 index 000000000000..78c768b0b3df --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2020_08_21_preview/operations/_application_definitions_operations.py @@ -0,0 +1,1160 @@ +# 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.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._vendor import MixinABC, _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_request( + resource_group_name: str, + application_definition_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-21-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "applicationDefinitionName": _SERIALIZER.url("application_definition_name", application_definition_name, 'str', max_length=64, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_delete_request( + resource_group_name: str, + application_definition_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-21-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "applicationDefinitionName": _SERIALIZER.url("application_definition_name", application_definition_name, 'str', max_length=64, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_create_or_update_request( + resource_group_name: str, + application_definition_name: str, + subscription_id: str, + *, + json: Optional[_models.ApplicationDefinition] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-21-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "applicationDefinitionName": _SERIALIZER.url("application_definition_name", application_definition_name, 'str', max_length=64, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_update_request( + subscription_id: str, + resource_group_name: str, + application_definition_name: str, + *, + json: Optional[_models.ApplicationDefinitionPatchable] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-21-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "applicationDefinitionName": _SERIALIZER.url("application_definition_name", application_definition_name, 'str', max_length=64, min_length=3), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_list_by_resource_group_request( + resource_group_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-21-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_list_by_subscription_request( + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-21-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Solutions/applicationDefinitions") + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_get_by_id_request( + resource_group_name: str, + application_definition_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-21-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "applicationDefinitionName": _SERIALIZER.url("application_definition_name", application_definition_name, 'str', max_length=64, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_delete_by_id_request( + resource_group_name: str, + application_definition_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-21-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "applicationDefinitionName": _SERIALIZER.url("application_definition_name", application_definition_name, 'str', max_length=64, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_create_or_update_by_id_request( + resource_group_name: str, + application_definition_name: str, + subscription_id: str, + *, + json: Optional[_models.ApplicationDefinition] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-21-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "applicationDefinitionName": _SERIALIZER.url("application_definition_name", application_definition_name, 'str', max_length=64, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_update_by_id_request( + subscription_id: str, + resource_group_name: str, + application_definition_name: str, + *, + json: Optional[_models.ApplicationDefinitionPatchable] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-21-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "applicationDefinitionName": _SERIALIZER.url("application_definition_name", application_definition_name, 'str', max_length=64, min_length=3), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + +class ApplicationDefinitionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.managedapplication.v2020_08_21_preview.ApplicationClient`'s + :attr:`application_definitions` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + + @distributed_trace + def get( + self, + resource_group_name: str, + application_definition_name: str, + **kwargs: Any + ) -> Optional[_models.ApplicationDefinition]: + """Gets the managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. + :type application_definition_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ApplicationDefinition, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2020_08_21_preview.models.ApplicationDefinition or None + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-21-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.ApplicationDefinition]] + + + request = build_get_request( + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('ApplicationDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore + + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + application_definition_name: str, + **kwargs: Any + ) -> None: + """Deletes the managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition to delete. + :type application_definition_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-21-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_request( + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore + + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + application_definition_name: str, + parameters: _models.ApplicationDefinition, + **kwargs: Any + ) -> _models.ApplicationDefinition: + """Creates a new managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. + :type application_definition_name: str + :param parameters: Parameters supplied to the create or update an managed application + definition. + :type parameters: + ~azure.mgmt.managedapplication.v2020_08_21_preview.models.ApplicationDefinition + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ApplicationDefinition, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2020_08_21_preview.models.ApplicationDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-21-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationDefinition] + + _json = self._serialize.body(parameters, 'ApplicationDefinition') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # 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, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('ApplicationDefinition', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('ApplicationDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore + + + @distributed_trace + def update( + self, + resource_group_name: str, + application_definition_name: str, + parameters: _models.ApplicationDefinitionPatchable, + **kwargs: Any + ) -> _models.ApplicationDefinition: + """Updates the managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. + :type application_definition_name: str + :param parameters: Parameters supplied to the update a managed application definition. + :type parameters: + ~azure.mgmt.managedapplication.v2020_08_21_preview.models.ApplicationDefinitionPatchable + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ApplicationDefinition, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2020_08_21_preview.models.ApplicationDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-21-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationDefinition] + + _json = self._serialize.body(parameters, 'ApplicationDefinitionPatchable') + + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ApplicationDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore + + + @distributed_trace + def list_by_resource_group( + self, + resource_group_name: str, + **kwargs: Any + ) -> Iterable[_models.ApplicationDefinitionListResult]: + """Lists the managed application definitions in a resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ApplicationDefinitionListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.managedapplication.v2020_08_21_preview.models.ApplicationDefinitionListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-21-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationDefinitionListResult] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_resource_group.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ApplicationDefinitionListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions"} # type: ignore + + @distributed_trace + def list_by_subscription( + self, + **kwargs: Any + ) -> Iterable[_models.ApplicationDefinitionListResult]: + """Lists the managed application definitions in a subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ApplicationDefinitionListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.managedapplication.v2020_08_21_preview.models.ApplicationDefinitionListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-21-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationDefinitionListResult] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ApplicationDefinitionListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Solutions/applicationDefinitions"} # type: ignore + + @distributed_trace + def get_by_id( + self, + resource_group_name: str, + application_definition_name: str, + **kwargs: Any + ) -> Optional[_models.ApplicationDefinition]: + """Gets the managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. + :type application_definition_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ApplicationDefinition, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2020_08_21_preview.models.ApplicationDefinition or None + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-21-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.ApplicationDefinition]] + + + request = build_get_by_id_request( + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_by_id.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('ApplicationDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_by_id.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore + + + @distributed_trace + def delete_by_id( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + application_definition_name: str, + **kwargs: Any + ) -> None: + """Deletes the managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. + :type application_definition_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-21-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_by_id_request( + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete_by_id.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete_by_id.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore + + + @distributed_trace + def create_or_update_by_id( + self, + resource_group_name: str, + application_definition_name: str, + parameters: _models.ApplicationDefinition, + **kwargs: Any + ) -> _models.ApplicationDefinition: + """Creates or updates a managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. + :type application_definition_name: str + :param parameters: Parameters supplied to the create or update a managed application + definition. + :type parameters: + ~azure.mgmt.managedapplication.v2020_08_21_preview.models.ApplicationDefinition + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ApplicationDefinition, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2020_08_21_preview.models.ApplicationDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-21-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationDefinition] + + _json = self._serialize.body(parameters, 'ApplicationDefinition') + + request = build_create_or_update_by_id_request( + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + 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'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # 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, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('ApplicationDefinition', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('ApplicationDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_or_update_by_id.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore + + + @distributed_trace + def update_by_id( + self, + resource_group_name: str, + application_definition_name: str, + parameters: _models.ApplicationDefinitionPatchable, + **kwargs: Any + ) -> _models.ApplicationDefinition: + """Updates the managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. + :type application_definition_name: str + :param parameters: Parameters supplied to the update a managed application definition. + :type parameters: + ~azure.mgmt.managedapplication.v2020_08_21_preview.models.ApplicationDefinitionPatchable + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ApplicationDefinition, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2020_08_21_preview.models.ApplicationDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-21-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationDefinition] + + _json = self._serialize.body(parameters, 'ApplicationDefinitionPatchable') + + request = build_update_by_id_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.update_by_id.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ApplicationDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + update_by_id.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore + diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2020_08_21_preview/operations/_applications_operations.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2020_08_21_preview/operations/_applications_operations.py new file mode 100644 index 000000000000..532f2712af28 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2020_08_21_preview/operations/_applications_operations.py @@ -0,0 +1,2025 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast + +from msrest import Serializer + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from .._vendor import MixinABC, _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_request( + resource_group_name: str, + application_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-21-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "applicationName": _SERIALIZER.url("application_name", application_name, 'str', max_length=64, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_delete_request_initial( + resource_group_name: str, + application_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-21-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "applicationName": _SERIALIZER.url("application_name", application_name, 'str', max_length=64, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_create_or_update_request_initial( + resource_group_name: str, + application_name: str, + subscription_id: str, + *, + json: Optional[_models.Application] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-21-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "applicationName": _SERIALIZER.url("application_name", application_name, 'str', max_length=64, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_update_request( + resource_group_name: str, + application_name: str, + subscription_id: str, + *, + json: Optional[_models.ApplicationPatchable] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-21-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "applicationName": _SERIALIZER.url("application_name", application_name, 'str', max_length=64, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_list_by_resource_group_request( + resource_group_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-21-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_list_by_subscription_request( + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-21-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Solutions/applications") + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_get_by_id_request( + application_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-21-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/{applicationId}") + path_format_arguments = { + "applicationId": _SERIALIZER.url("application_id", application_id, 'str', skip_quote=True), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_delete_by_id_request_initial( + application_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-21-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/{applicationId}") + path_format_arguments = { + "applicationId": _SERIALIZER.url("application_id", application_id, 'str', skip_quote=True), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_create_or_update_by_id_request_initial( + application_id: str, + *, + json: Optional[_models.Application] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-21-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/{applicationId}") + path_format_arguments = { + "applicationId": _SERIALIZER.url("application_id", application_id, 'str', skip_quote=True), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_update_by_id_request_initial( + application_id: str, + *, + json: Optional[_models.ApplicationPatchable] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-21-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/{applicationId}") + path_format_arguments = { + "applicationId": _SERIALIZER.url("application_id", application_id, 'str', skip_quote=True), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_refresh_permissions_request_initial( + resource_group_name: str, + application_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-21-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}/refreshPermissions") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "applicationName": _SERIALIZER.url("application_name", application_name, 'str', max_length=64, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_list_allowed_upgrade_plans_request( + subscription_id: str, + resource_group_name: str, + application_name: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-21-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}/listAllowedUpgradePlans") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "applicationName": _SERIALIZER.url("application_name", application_name, 'str', max_length=64, min_length=3), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_update_access_request_initial( + subscription_id: str, + resource_group_name: str, + application_name: str, + *, + json: Optional[_models.UpdateAccessDefinition] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-21-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}/updateAccess") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "applicationName": _SERIALIZER.url("application_name", application_name, 'str', max_length=64, min_length=3), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_list_tokens_request( + subscription_id: str, + resource_group_name: str, + application_name: str, + *, + json: Optional[_models.ListTokenRequest] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-21-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}/listTokens") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "applicationName": _SERIALIZER.url("application_name", application_name, 'str', max_length=64, min_length=3), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + +class ApplicationsOperations: # pylint: disable=too-many-public-methods + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.managedapplication.v2020_08_21_preview.ApplicationClient`'s + :attr:`applications` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + + @distributed_trace + def get( + self, + resource_group_name: str, + application_name: str, + **kwargs: Any + ) -> Optional[_models.Application]: + """Gets the managed application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_name: The name of the managed application. + :type application_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Application, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2020_08_21_preview.models.Application or None + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-21-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.Application]] + + + request = build_get_request( + resource_group_name=resource_group_name, + application_name=application_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('Application', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}"} # type: ignore + + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + application_name: str, + **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-21-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + application_name=application_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}"} # type: ignore + + + @distributed_trace + def begin_delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + application_name: str, + **kwargs: Any + ) -> LROPoller[None]: + """Deletes the managed application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_name: The name of the managed application. + :type application_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-21-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._delete_initial( # type: ignore + resource_group_name=resource_group_name, + application_name=application_name, + api_version=api_version, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}"} # type: ignore + + def _create_or_update_initial( + self, + resource_group_name: str, + application_name: str, + parameters: _models.Application, + **kwargs: Any + ) -> _models.Application: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-21-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Application] + + _json = self._serialize.body(parameters, 'Application') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + application_name=application_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('Application', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('Application', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}"} # type: ignore + + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + application_name: str, + parameters: _models.Application, + **kwargs: Any + ) -> LROPoller[_models.Application]: + """Creates or update managed application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_name: The name of the managed application. + :type application_name: str + :param parameters: Parameters supplied to the create or update a managed application. + :type parameters: ~azure.mgmt.managedapplication.v2020_08_21_preview.models.Application + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Application or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.managedapplication.v2020_08_21_preview.models.Application] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-21-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Application] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._create_or_update_initial( # type: ignore + resource_group_name=resource_group_name, + application_name=application_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('Application', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}"} # type: ignore + + @distributed_trace + def update( + self, + resource_group_name: str, + application_name: str, + parameters: Optional[_models.ApplicationPatchable] = None, + **kwargs: Any + ) -> _models.ApplicationPatchable: + """Updates an existing managed application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_name: The name of the managed application. + :type application_name: str + :param parameters: Parameters supplied to update an existing managed application. Default value + is None. + :type parameters: + ~azure.mgmt.managedapplication.v2020_08_21_preview.models.ApplicationPatchable + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ApplicationPatchable, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2020_08_21_preview.models.ApplicationPatchable + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-21-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationPatchable] + + if parameters is not None: + _json = self._serialize.body(parameters, 'ApplicationPatchable') + else: + _json = None + + request = build_update_request( + resource_group_name=resource_group_name, + application_name=application_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('ApplicationPatchable', pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize('ApplicationPatchable', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}"} # type: ignore + + + @distributed_trace + def list_by_resource_group( + self, + resource_group_name: str, + **kwargs: Any + ) -> Iterable[_models.ApplicationListResult]: + """Gets all the applications within a resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ApplicationListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.managedapplication.v2020_08_21_preview.models.ApplicationListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-21-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationListResult] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_resource_group.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ApplicationListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications"} # type: ignore + + @distributed_trace + def list_by_subscription( + self, + **kwargs: Any + ) -> Iterable[_models.ApplicationListResult]: + """Lists all the applications within a subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ApplicationListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.managedapplication.v2020_08_21_preview.models.ApplicationListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-21-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationListResult] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ApplicationListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Solutions/applications"} # type: ignore + + @distributed_trace + def get_by_id( + self, + application_id: str, + **kwargs: Any + ) -> Optional[_models.Application]: + """Gets the managed application. + + :param application_id: The fully qualified ID of the managed application, including the managed + application name and the managed application resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/Microsoft.Solutions/applications/{application-name}. + :type application_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Application, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2020_08_21_preview.models.Application or None + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-21-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.Application]] + + + request = build_get_by_id_request( + application_id=application_id, + api_version=api_version, + template_url=self.get_by_id.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('Application', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_by_id.metadata = {'url': "/{applicationId}"} # type: ignore + + + def _delete_by_id_initial( # pylint: disable=inconsistent-return-statements + self, + application_id: str, + **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-21-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_by_id_request_initial( + application_id=application_id, + api_version=api_version, + template_url=self._delete_by_id_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_by_id_initial.metadata = {'url': "/{applicationId}"} # type: ignore + + + @distributed_trace + def begin_delete_by_id( # pylint: disable=inconsistent-return-statements + self, + application_id: str, + **kwargs: Any + ) -> LROPoller[None]: + """Deletes the managed application. + + :param application_id: The fully qualified ID of the managed application, including the managed + application name and the managed application resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/Microsoft.Solutions/applications/{application-name}. + :type application_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-21-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._delete_by_id_initial( # type: ignore + application_id=application_id, + api_version=api_version, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete_by_id.metadata = {'url': "/{applicationId}"} # type: ignore + + def _create_or_update_by_id_initial( + self, + application_id: str, + parameters: _models.Application, + **kwargs: Any + ) -> _models.Application: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-21-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Application] + + _json = self._serialize.body(parameters, 'Application') + + request = build_create_or_update_by_id_request_initial( + application_id=application_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._create_or_update_by_id_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('Application', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('Application', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_by_id_initial.metadata = {'url': "/{applicationId}"} # type: ignore + + + @distributed_trace + def begin_create_or_update_by_id( + self, + application_id: str, + parameters: _models.Application, + **kwargs: Any + ) -> LROPoller[_models.Application]: + """Creates or updates a managed application. + + :param application_id: The fully qualified ID of the managed application, including the managed + application name and the managed application resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/Microsoft.Solutions/applications/{application-name}. + :type application_id: str + :param parameters: Parameters supplied to the create or update a managed application. + :type parameters: ~azure.mgmt.managedapplication.v2020_08_21_preview.models.Application + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Application or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.managedapplication.v2020_08_21_preview.models.Application] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-21-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Application] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._create_or_update_by_id_initial( # type: ignore + application_id=application_id, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('Application', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update_by_id.metadata = {'url': "/{applicationId}"} # type: ignore + + def _update_by_id_initial( + self, + application_id: str, + parameters: Optional[_models.ApplicationPatchable] = None, + **kwargs: Any + ) -> _models.ApplicationPatchable: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-21-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationPatchable] + + if parameters is not None: + _json = self._serialize.body(parameters, 'ApplicationPatchable') + else: + _json = None + + request = build_update_by_id_request_initial( + application_id=application_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._update_by_id_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('ApplicationPatchable', pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize('ApplicationPatchable', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _update_by_id_initial.metadata = {'url': "/{applicationId}"} # type: ignore + + + @distributed_trace + def begin_update_by_id( + self, + application_id: str, + parameters: Optional[_models.ApplicationPatchable] = None, + **kwargs: Any + ) -> LROPoller[_models.ApplicationPatchable]: + """Updates an existing managed application. + + :param application_id: The fully qualified ID of the managed application, including the managed + application name and the managed application resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/Microsoft.Solutions/applications/{application-name}. + :type application_id: str + :param parameters: Parameters supplied to update an existing managed application. Default value + is None. + :type parameters: + ~azure.mgmt.managedapplication.v2020_08_21_preview.models.ApplicationPatchable + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ApplicationPatchable or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.managedapplication.v2020_08_21_preview.models.ApplicationPatchable] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-21-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationPatchable] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._update_by_id_initial( # type: ignore + application_id=application_id, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('ApplicationPatchable', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_update_by_id.metadata = {'url': "/{applicationId}"} # type: ignore + + def _refresh_permissions_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + application_name: str, + **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-21-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_refresh_permissions_request_initial( + resource_group_name=resource_group_name, + application_name=application_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._refresh_permissions_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _refresh_permissions_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}/refreshPermissions"} # type: ignore + + + @distributed_trace + def begin_refresh_permissions( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + application_name: str, + **kwargs: Any + ) -> LROPoller[None]: + """Refresh Permissions for application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_name: The name of the managed application. + :type application_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-21-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._refresh_permissions_initial( # type: ignore + resource_group_name=resource_group_name, + application_name=application_name, + api_version=api_version, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'location'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_refresh_permissions.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}/refreshPermissions"} # type: ignore + + @distributed_trace + def list_allowed_upgrade_plans( + self, + resource_group_name: str, + application_name: str, + **kwargs: Any + ) -> _models.AllowedUpgradePlansResult: + """List allowed upgrade plans for application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_name: The name of the managed application. + :type application_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AllowedUpgradePlansResult, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2020_08_21_preview.models.AllowedUpgradePlansResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-21-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AllowedUpgradePlansResult] + + + request = build_list_allowed_upgrade_plans_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + application_name=application_name, + api_version=api_version, + template_url=self.list_allowed_upgrade_plans.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('AllowedUpgradePlansResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_allowed_upgrade_plans.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}/listAllowedUpgradePlans"} # type: ignore + + + def _update_access_initial( + self, + resource_group_name: str, + application_name: str, + parameters: _models.UpdateAccessDefinition, + **kwargs: Any + ) -> Optional[_models.UpdateAccessDefinition]: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-21-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.UpdateAccessDefinition]] + + _json = self._serialize.body(parameters, 'UpdateAccessDefinition') + + request = build_update_access_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + application_name=application_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._update_access_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 202: + deserialized = self._deserialize('UpdateAccessDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _update_access_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}/updateAccess"} # type: ignore + + + @distributed_trace + def begin_update_access( + self, + resource_group_name: str, + application_name: str, + parameters: _models.UpdateAccessDefinition, + **kwargs: Any + ) -> LROPoller[_models.UpdateAccessDefinition]: + """Update access for application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_name: The name of the managed application. + :type application_name: str + :param parameters: Request body parameters to update access. + :type parameters: + ~azure.mgmt.managedapplication.v2020_08_21_preview.models.UpdateAccessDefinition + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either UpdateAccessDefinition or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.managedapplication.v2020_08_21_preview.models.UpdateAccessDefinition] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-21-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.UpdateAccessDefinition] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._update_access_initial( # type: ignore + resource_group_name=resource_group_name, + application_name=application_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('UpdateAccessDefinition', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'location'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_update_access.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}/updateAccess"} # type: ignore + + @distributed_trace + def list_tokens( + self, + resource_group_name: str, + application_name: str, + parameters: _models.ListTokenRequest, + **kwargs: Any + ) -> _models.ManagedIdentityTokenResult: + """List tokens for application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_name: The name of the managed application. + :type application_name: str + :param parameters: Request body parameters to list tokens. + :type parameters: ~azure.mgmt.managedapplication.v2020_08_21_preview.models.ListTokenRequest + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ManagedIdentityTokenResult, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2020_08_21_preview.models.ManagedIdentityTokenResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-21-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ManagedIdentityTokenResult] + + _json = self._serialize.body(parameters, 'ListTokenRequest') + + request = build_list_tokens_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + application_name=application_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.list_tokens.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ManagedIdentityTokenResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_tokens.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}/listTokens"} # type: ignore + diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2020_08_21_preview/operations/_jit_requests_operations.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2020_08_21_preview/operations/_jit_requests_operations.py new file mode 100644 index 000000000000..81348a475de0 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2020_08_21_preview/operations/_jit_requests_operations.py @@ -0,0 +1,739 @@ +# 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, Union, cast + +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.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from .._vendor import MixinABC, _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_request( + resource_group_name: str, + jit_request_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-21-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/jitRequests/{jitRequestName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "jitRequestName": _SERIALIZER.url("jit_request_name", jit_request_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_create_or_update_request_initial( + resource_group_name: str, + jit_request_name: str, + subscription_id: str, + *, + json: Optional[_models.JitRequestDefinition] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-21-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/jitRequests/{jitRequestName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "jitRequestName": _SERIALIZER.url("jit_request_name", jit_request_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_update_request( + resource_group_name: str, + jit_request_name: str, + subscription_id: str, + *, + json: Optional[_models.JitRequestPatchable] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-21-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/jitRequests/{jitRequestName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "jitRequestName": _SERIALIZER.url("jit_request_name", jit_request_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request( + resource_group_name: str, + jit_request_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-21-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/jitRequests/{jitRequestName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "jitRequestName": _SERIALIZER.url("jit_request_name", jit_request_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_list_by_subscription_request( + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-21-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Solutions/jitRequests") + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_list_by_resource_group_request( + resource_group_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-21-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/jitRequests") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + +class JitRequestsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.managedapplication.v2020_08_21_preview.ApplicationClient`'s + :attr:`jit_requests` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + + @distributed_trace + def get( + self, + resource_group_name: str, + jit_request_name: str, + **kwargs: Any + ) -> Optional[_models.JitRequestDefinition]: + """Gets the JIT request. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param jit_request_name: The name of the JIT request. + :type jit_request_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JitRequestDefinition, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2020_08_21_preview.models.JitRequestDefinition or None + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-21-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.JitRequestDefinition]] + + + request = build_get_request( + resource_group_name=resource_group_name, + jit_request_name=jit_request_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('JitRequestDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/jitRequests/{jitRequestName}"} # type: ignore + + + def _create_or_update_initial( + self, + resource_group_name: str, + jit_request_name: str, + parameters: _models.JitRequestDefinition, + **kwargs: Any + ) -> _models.JitRequestDefinition: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-21-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.JitRequestDefinition] + + _json = self._serialize.body(parameters, 'JitRequestDefinition') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + jit_request_name=jit_request_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('JitRequestDefinition', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('JitRequestDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/jitRequests/{jitRequestName}"} # type: ignore + + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + jit_request_name: str, + parameters: _models.JitRequestDefinition, + **kwargs: Any + ) -> LROPoller[_models.JitRequestDefinition]: + """Creates or updates the JIT request. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param jit_request_name: The name of the JIT request. + :type jit_request_name: str + :param parameters: Parameters supplied to the update JIT request. + :type parameters: + ~azure.mgmt.managedapplication.v2020_08_21_preview.models.JitRequestDefinition + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either JitRequestDefinition or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.managedapplication.v2020_08_21_preview.models.JitRequestDefinition] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-21-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.JitRequestDefinition] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._create_or_update_initial( # type: ignore + resource_group_name=resource_group_name, + jit_request_name=jit_request_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('JitRequestDefinition', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/jitRequests/{jitRequestName}"} # type: ignore + + @distributed_trace + def update( + self, + resource_group_name: str, + jit_request_name: str, + parameters: _models.JitRequestPatchable, + **kwargs: Any + ) -> _models.JitRequestDefinition: + """Updates the JIT request. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param jit_request_name: The name of the JIT request. + :type jit_request_name: str + :param parameters: Parameters supplied to the update JIT request. + :type parameters: ~azure.mgmt.managedapplication.v2020_08_21_preview.models.JitRequestPatchable + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JitRequestDefinition, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2020_08_21_preview.models.JitRequestDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-21-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.JitRequestDefinition] + + _json = self._serialize.body(parameters, 'JitRequestPatchable') + + request = build_update_request( + resource_group_name=resource_group_name, + jit_request_name=jit_request_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('JitRequestDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/jitRequests/{jitRequestName}"} # type: ignore + + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + jit_request_name: str, + **kwargs: Any + ) -> None: + """Deletes the JIT request. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param jit_request_name: The name of the JIT request. + :type jit_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 + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-21-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_request( + resource_group_name=resource_group_name, + jit_request_name=jit_request_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/jitRequests/{jitRequestName}"} # type: ignore + + + @distributed_trace + def list_by_subscription( + self, + **kwargs: Any + ) -> _models.JitRequestDefinitionListResult: + """Lists all JIT requests within the subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JitRequestDefinitionListResult, or the result of cls(response) + :rtype: + ~azure.mgmt.managedapplication.v2020_08_21_preview.models.JitRequestDefinitionListResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-21-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.JitRequestDefinitionListResult] + + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('JitRequestDefinitionListResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Solutions/jitRequests"} # type: ignore + + + @distributed_trace + def list_by_resource_group( + self, + resource_group_name: str, + **kwargs: Any + ) -> _models.JitRequestDefinitionListResult: + """Lists all JIT requests within the 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: JitRequestDefinitionListResult, or the result of cls(response) + :rtype: + ~azure.mgmt.managedapplication.v2020_08_21_preview.models.JitRequestDefinitionListResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-21-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.JitRequestDefinitionListResult] + + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_resource_group.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('JitRequestDefinitionListResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/jitRequests"} # type: ignore + diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2020_08_21_preview/operations/_patch.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2020_08_21_preview/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2020_08_21_preview/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2020_08_21_preview/py.typed b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2020_08_21_preview/py.typed new file mode 100644 index 000000000000..e5aff4f83af8 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2020_08_21_preview/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_02_01_preview/__init__.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_02_01_preview/__init__.py new file mode 100644 index 000000000000..2e61ca12e56a --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_02_01_preview/__init__.py @@ -0,0 +1,23 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._application_client import ApplicationClient +from ._version import VERSION + +__version__ = VERSION + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk +__all__ = ['ApplicationClient'] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_02_01_preview/_application_client.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_02_01_preview/_application_client.py new file mode 100644 index 000000000000..1bde70d9f4c0 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_02_01_preview/_application_client.py @@ -0,0 +1,112 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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 ApplicationClientConfiguration +from .operations import ApplicationClientOperationsMixin, ApplicationDefinitionsOperations, ApplicationsOperations, JitRequestsOperations + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential + +class ApplicationClient(ApplicationClientOperationsMixin): + """ARM applications. + + :ivar applications: ApplicationsOperations operations + :vartype applications: + azure.mgmt.managedapplication.v2021_02_01_preview.operations.ApplicationsOperations + :ivar application_definitions: ApplicationDefinitionsOperations operations + :vartype application_definitions: + azure.mgmt.managedapplication.v2021_02_01_preview.operations.ApplicationDefinitionsOperations + :ivar jit_requests: JitRequestsOperations operations + :vartype jit_requests: + azure.mgmt.managedapplication.v2021_02_01_preview.operations.JitRequestsOperations + :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-02-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + """ + + def __init__( + self, + credential: "TokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = ApplicationClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.applications = ApplicationsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.application_definitions = ApplicationDefinitionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.jit_requests = JitRequestsOperations( + 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: () -> ApplicationClient + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (Any) -> None + self._client.__exit__(*exc_details) diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_02_01_preview/_configuration.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_02_01_preview/_configuration.py new file mode 100644 index 000000000000..88b6b07f2073 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_02_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 ApplicationClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes + """Configuration for ApplicationClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials.TokenCredential + :param subscription_id: The ID of the target subscription. + :type subscription_id: str + :keyword api_version: Api Version. Default value is "2021-02-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(ApplicationClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2021-02-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-managedapplication/{}'.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/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_02_01_preview/_metadata.json b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_02_01_preview/_metadata.json new file mode 100644 index 000000000000..46f34c3c0ef5 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_02_01_preview/_metadata.json @@ -0,0 +1,123 @@ +{ + "chosen_version": "2021-02-01-preview", + "total_api_version_list": ["2021-02-01-preview"], + "client": { + "name": "ApplicationClient", + "filename": "_application_client", + "description": "ARM applications.", + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": null, + "azure_arm": true, + "has_lro_operations": true, + "client_side_validation": false, + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ApplicationClientConfiguration\"], \"._operations_mixin\": [\"ApplicationClientOperationsMixin\"]}, \"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\": [\"ApplicationClientConfiguration\"], \"._operations_mixin\": [\"ApplicationClientOperationsMixin\"]}, \"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": { + "applications": "ApplicationsOperations", + "application_definitions": "ApplicationDefinitionsOperations", + "jit_requests": "JitRequestsOperations" + }, + "operation_mixins": { + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Iterable\"]}, \"azurecore\": {\"azure.core.paging\": [\"ItemPaged\"]}}, \"regular\": {\"local\": {\".\": [[\"models\", \"_models\"]]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"AsyncIterable\"]}, \"azurecore\": {\"azure.core.async_paging\": [\"AsyncItemPaged\"]}}, \"regular\": {\"local\": {\"..\": [[\"models\", \"_models\"]]}}}", + "operations": { + "list_operations" : { + "sync": { + "signature": "def list_operations(\n self,\n **kwargs # type: Any\n):\n # type: (...) -\u003e Iterable[_models.OperationListResult]\n", + "doc": "\"\"\"Lists all of the available Microsoft.Solutions REST API operations.\n\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: An iterator like instance of either OperationListResult or the result of cls(response)\n:rtype:\n ~azure.core.paging.ItemPaged[~azure.mgmt.managedapplication.v2021_02_01_preview.models.OperationListResult]\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"", + "call": "**kwargs" + }, + "async": { + "coroutine": false, + "signature": "def list_operations(\n self,\n **kwargs: Any\n) -\u003e AsyncIterable[_models.OperationListResult]:\n", + "doc": "\"\"\"Lists all of the available Microsoft.Solutions REST API operations.\n\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: An iterator like instance of either OperationListResult or the result of cls(response)\n:rtype:\n ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.managedapplication.v2021_02_01_preview.models.OperationListResult]\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"", + "call": "**kwargs" + } + } + } + } +} \ No newline at end of file diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_02_01_preview/_patch.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_02_01_preview/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_02_01_preview/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_02_01_preview/_vendor.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_02_01_preview/_vendor.py new file mode 100644 index 000000000000..bf1845cabc0f --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_02_01_preview/_vendor.py @@ -0,0 +1,45 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from abc import ABC +from typing import TYPE_CHECKING + +from azure.core.pipeline.transport import HttpRequest + +from ._configuration import ApplicationClientConfiguration + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from msrest import Deserializer, Serializer + + from azure.core import PipelineClient + +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) + +class MixinABC(ABC): + """DO NOT use this class. It is for internal typing use only.""" + _client: "PipelineClient" + _config: ApplicationClientConfiguration + _serialize: "Serializer" + _deserialize: "Deserializer" diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_02_01_preview/_version.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_02_01_preview/_version.py new file mode 100644 index 000000000000..e5754a47ce68 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_02_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/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_02_01_preview/aio/__init__.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_02_01_preview/aio/__init__.py new file mode 100644 index 000000000000..c90626a31421 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_02_01_preview/aio/__init__.py @@ -0,0 +1,20 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._application_client import ApplicationClient + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk +__all__ = ['ApplicationClient'] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_02_01_preview/aio/_application_client.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_02_01_preview/aio/_application_client.py new file mode 100644 index 000000000000..fa18943c9671 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_02_01_preview/aio/_application_client.py @@ -0,0 +1,109 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# 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 ApplicationClientConfiguration +from .operations import ApplicationClientOperationsMixin, ApplicationDefinitionsOperations, ApplicationsOperations, JitRequestsOperations + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + +class ApplicationClient(ApplicationClientOperationsMixin): + """ARM applications. + + :ivar applications: ApplicationsOperations operations + :vartype applications: + azure.mgmt.managedapplication.v2021_02_01_preview.aio.operations.ApplicationsOperations + :ivar application_definitions: ApplicationDefinitionsOperations operations + :vartype application_definitions: + azure.mgmt.managedapplication.v2021_02_01_preview.aio.operations.ApplicationDefinitionsOperations + :ivar jit_requests: JitRequestsOperations operations + :vartype jit_requests: + azure.mgmt.managedapplication.v2021_02_01_preview.aio.operations.JitRequestsOperations + :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-02-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = ApplicationClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.applications = ApplicationsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.application_definitions = ApplicationDefinitionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.jit_requests = JitRequestsOperations( + 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) -> "ApplicationClient": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_02_01_preview/aio/_configuration.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_02_01_preview/aio/_configuration.py new file mode 100644 index 000000000000..1ebcf08667b5 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_02_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 ApplicationClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes + """Configuration for ApplicationClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :param subscription_id: The ID of the target subscription. + :type subscription_id: str + :keyword api_version: Api Version. Default value is "2021-02-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(ApplicationClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2021-02-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-managedapplication/{}'.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/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_02_01_preview/aio/_patch.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_02_01_preview/aio/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_02_01_preview/aio/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_02_01_preview/aio/_vendor.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_02_01_preview/aio/_vendor.py new file mode 100644 index 000000000000..da14e4f71f0e --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_02_01_preview/aio/_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 abc import ABC +from typing import TYPE_CHECKING + +from azure.core.pipeline.transport import HttpRequest + +from ._configuration import ApplicationClientConfiguration + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from msrest import Deserializer, Serializer + + from azure.core import AsyncPipelineClient + + +class MixinABC(ABC): + """DO NOT use this class. It is for internal typing use only.""" + _client: "AsyncPipelineClient" + _config: ApplicationClientConfiguration + _serialize: "Serializer" + _deserialize: "Deserializer" diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_02_01_preview/aio/operations/__init__.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_02_01_preview/aio/operations/__init__.py new file mode 100644 index 000000000000..b93ecbbe65e2 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_02_01_preview/aio/operations/__init__.py @@ -0,0 +1,24 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._application_client_operations import ApplicationClientOperationsMixin +from ._applications_operations import ApplicationsOperations +from ._application_definitions_operations import ApplicationDefinitionsOperations +from ._jit_requests_operations import JitRequestsOperations + +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk +__all__ = [ + 'ApplicationClientOperationsMixin', + 'ApplicationsOperations', + 'ApplicationDefinitionsOperations', + 'JitRequestsOperations', +] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_02_01_preview/aio/operations/_application_client_operations.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_02_01_preview/aio/operations/_application_client_operations.py new file mode 100644 index 000000000000..34a8a500b3c5 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_02_01_preview/aio/operations/_application_client_operations.py @@ -0,0 +1,105 @@ +# 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.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._application_client_operations import build_list_operations_request +from .._vendor import MixinABC +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class ApplicationClientOperationsMixin(MixinABC): + + @distributed_trace + def list_operations( + self, + **kwargs: Any + ) -> AsyncIterable[_models.OperationListResult]: + """Lists all of the available Microsoft.Solutions REST API operations. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either OperationListResult or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.managedapplication.v2021_02_01_preview.models.OperationListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-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', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_operations_request( + api_version=api_version, + template_url=self.list_operations.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_operations_request( + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list_operations.metadata = {'url': "/providers/Microsoft.Solutions/operations"} # type: ignore diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_02_01_preview/aio/operations/_application_definitions_operations.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_02_01_preview/aio/operations/_application_definitions_operations.py new file mode 100644 index 000000000000..64b5d464e8b2 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_02_01_preview/aio/operations/_application_definitions_operations.py @@ -0,0 +1,763 @@ +# 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.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._application_definitions_operations import build_create_or_update_by_id_request, build_create_or_update_request, build_delete_by_id_request, build_delete_request, build_get_by_id_request, build_get_request, build_list_by_resource_group_request, build_list_by_subscription_request, build_update_by_id_request, build_update_request +from .._vendor import MixinABC +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class ApplicationDefinitionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.managedapplication.v2021_02_01_preview.aio.ApplicationClient`'s + :attr:`application_definitions` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + application_definition_name: str, + **kwargs: Any + ) -> Optional[_models.ApplicationDefinition]: + """Gets the managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. + :type application_definition_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ApplicationDefinition, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2021_02_01_preview.models.ApplicationDefinition or None + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.ApplicationDefinition]] + + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('ApplicationDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore + + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + application_definition_name: str, + **kwargs: Any + ) -> None: + """Deletes the managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. + :type application_definition_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + api_version=api_version, + template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore + + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + application_definition_name: str, + parameters: _models.ApplicationDefinition, + **kwargs: Any + ) -> _models.ApplicationDefinition: + """Creates or updates a managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. + :type application_definition_name: str + :param parameters: Parameters supplied to the create or update an managed application + definition. + :type parameters: + ~azure.mgmt.managedapplication.v2021_02_01_preview.models.ApplicationDefinition + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ApplicationDefinition, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2021_02_01_preview.models.ApplicationDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationDefinition] + + _json = self._serialize.body(parameters, 'ApplicationDefinition') + + request = build_create_or_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # 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, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('ApplicationDefinition', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('ApplicationDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore + + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + application_definition_name: str, + parameters: _models.ApplicationDefinitionPatchable, + **kwargs: Any + ) -> _models.ApplicationDefinition: + """Updates the managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. + :type application_definition_name: str + :param parameters: Parameters supplied to the update a managed application definition. + :type parameters: + ~azure.mgmt.managedapplication.v2021_02_01_preview.models.ApplicationDefinitionPatchable + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ApplicationDefinition, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2021_02_01_preview.models.ApplicationDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationDefinition] + + _json = self._serialize.body(parameters, 'ApplicationDefinitionPatchable') + + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ApplicationDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore + + + @distributed_trace + def list_by_resource_group( + self, + resource_group_name: str, + **kwargs: Any + ) -> AsyncIterable[_models.ApplicationDefinitionListResult]: + """Lists the managed application definitions in a resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ApplicationDefinitionListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.managedapplication.v2021_02_01_preview.models.ApplicationDefinitionListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationDefinitionListResult] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + api_version=api_version, + template_url=self.list_by_resource_group.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ApplicationDefinitionListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions"} # type: ignore + + @distributed_trace + def list_by_subscription( + self, + **kwargs: Any + ) -> AsyncIterable[_models.ApplicationDefinitionListResult]: + """Gets all the application definitions within a subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ApplicationDefinitionListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.managedapplication.v2021_02_01_preview.models.ApplicationDefinitionListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationDefinitionListResult] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ApplicationDefinitionListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Solutions/applicationDefinitions"} # type: ignore + + @distributed_trace_async + async def get_by_id( + self, + resource_group_name: str, + application_definition_name: str, + **kwargs: Any + ) -> Optional[_models.ApplicationDefinition]: + """Gets the managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. + :type application_definition_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ApplicationDefinition, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2021_02_01_preview.models.ApplicationDefinition or None + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.ApplicationDefinition]] + + + request = build_get_by_id_request( + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_by_id.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('ApplicationDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_by_id.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore + + + @distributed_trace_async + async def delete_by_id( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + application_definition_name: str, + **kwargs: Any + ) -> None: + """Deletes the managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. + :type application_definition_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_by_id_request( + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete_by_id.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete_by_id.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore + + + @distributed_trace_async + async def create_or_update_by_id( + self, + resource_group_name: str, + application_definition_name: str, + parameters: _models.ApplicationDefinition, + **kwargs: Any + ) -> _models.ApplicationDefinition: + """Creates or updates managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. + :type application_definition_name: str + :param parameters: Parameters supplied to the create or update a managed application + definition. + :type parameters: + ~azure.mgmt.managedapplication.v2021_02_01_preview.models.ApplicationDefinition + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ApplicationDefinition, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2021_02_01_preview.models.ApplicationDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationDefinition] + + _json = self._serialize.body(parameters, 'ApplicationDefinition') + + request = build_create_or_update_by_id_request( + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + 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'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # 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, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('ApplicationDefinition', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('ApplicationDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_or_update_by_id.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore + + + @distributed_trace_async + async def update_by_id( + self, + resource_group_name: str, + application_definition_name: str, + parameters: _models.ApplicationDefinitionPatchable, + **kwargs: Any + ) -> _models.ApplicationDefinition: + """Updates the managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. + :type application_definition_name: str + :param parameters: Parameters supplied to the update a managed application definition. + :type parameters: + ~azure.mgmt.managedapplication.v2021_02_01_preview.models.ApplicationDefinitionPatchable + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ApplicationDefinition, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2021_02_01_preview.models.ApplicationDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationDefinition] + + _json = self._serialize.body(parameters, 'ApplicationDefinitionPatchable') + + request = build_update_by_id_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.update_by_id.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ApplicationDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + update_by_id.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore + diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_02_01_preview/aio/operations/_applications_operations.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_02_01_preview/aio/operations/_applications_operations.py new file mode 100644 index 000000000000..1e45e16e26d3 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_02_01_preview/aio/operations/_applications_operations.py @@ -0,0 +1,1548 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union, cast + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._applications_operations import build_create_or_update_by_id_request_initial, build_create_or_update_request_initial, build_delete_by_id_request_initial, build_delete_request_initial, build_get_by_id_request, build_get_request, build_list_allowed_upgrade_plans_request, build_list_by_resource_group_request, build_list_by_subscription_request, build_list_tokens_request, build_refresh_permissions_request_initial, build_update_access_request_initial, build_update_by_id_request_initial, build_update_request_initial +from .._vendor import MixinABC +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class ApplicationsOperations: # pylint: disable=too-many-public-methods + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.managedapplication.v2021_02_01_preview.aio.ApplicationClient`'s + :attr:`applications` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + application_name: str, + **kwargs: Any + ) -> Optional[_models.Application]: + """Gets the managed application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_name: The name of the managed application. + :type application_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Application, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2021_02_01_preview.models.Application or None + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.Application]] + + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + application_name=application_name, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('Application', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}"} # type: ignore + + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + application_name: str, + **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + application_name=application_name, + api_version=api_version, + template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}"} # type: ignore + + + @distributed_trace_async + async def begin_delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + application_name: str, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes the managed application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_name: The name of the managed application. + :type application_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._delete_initial( # type: ignore + resource_group_name=resource_group_name, + application_name=application_name, + api_version=api_version, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}"} # type: ignore + + async def _create_or_update_initial( + self, + resource_group_name: str, + application_name: str, + parameters: _models.Application, + **kwargs: Any + ) -> _models.Application: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Application] + + _json = self._serialize.body(parameters, 'Application') + + request = build_create_or_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + application_name=application_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('Application', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('Application', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}"} # type: ignore + + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + application_name: str, + parameters: _models.Application, + **kwargs: Any + ) -> AsyncLROPoller[_models.Application]: + """Creates or update managed application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_name: The name of the managed application. + :type application_name: str + :param parameters: Parameters supplied to the create or update a managed application. + :type parameters: ~azure.mgmt.managedapplication.v2021_02_01_preview.models.Application + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either Application or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.managedapplication.v2021_02_01_preview.models.Application] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Application] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._create_or_update_initial( # type: ignore + resource_group_name=resource_group_name, + application_name=application_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('Application', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}"} # type: ignore + + async def _update_initial( + self, + resource_group_name: str, + application_name: str, + parameters: Optional[_models.ApplicationPatchable] = None, + **kwargs: Any + ) -> _models.ApplicationPatchable: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationPatchable] + + if parameters is not None: + _json = self._serialize.body(parameters, 'ApplicationPatchable') + else: + _json = None + + request = build_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + application_name=application_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('ApplicationPatchable', pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize('ApplicationPatchable', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}"} # type: ignore + + + @distributed_trace_async + async def begin_update( + self, + resource_group_name: str, + application_name: str, + parameters: Optional[_models.ApplicationPatchable] = None, + **kwargs: Any + ) -> AsyncLROPoller[_models.ApplicationPatchable]: + """Updates an existing managed application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_name: The name of the managed application. + :type application_name: str + :param parameters: Parameters supplied to update an existing managed application. Default value + is None. + :type parameters: + ~azure.mgmt.managedapplication.v2021_02_01_preview.models.ApplicationPatchable + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ApplicationPatchable or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.managedapplication.v2021_02_01_preview.models.ApplicationPatchable] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationPatchable] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._update_initial( # type: ignore + resource_group_name=resource_group_name, + application_name=application_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('ApplicationPatchable', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}"} # type: ignore + + @distributed_trace + def list_by_resource_group( + self, + resource_group_name: str, + **kwargs: Any + ) -> AsyncIterable[_models.ApplicationListResult]: + """Gets all the applications within a resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ApplicationListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.managedapplication.v2021_02_01_preview.models.ApplicationListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationListResult] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + api_version=api_version, + template_url=self.list_by_resource_group.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ApplicationListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications"} # type: ignore + + @distributed_trace + def list_by_subscription( + self, + **kwargs: Any + ) -> AsyncIterable[_models.ApplicationListResult]: + """Gets all the applications within a subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ApplicationListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.managedapplication.v2021_02_01_preview.models.ApplicationListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationListResult] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ApplicationListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Solutions/applications"} # type: ignore + + @distributed_trace_async + async def get_by_id( + self, + application_id: str, + **kwargs: Any + ) -> Optional[_models.Application]: + """Gets the managed application. + + :param application_id: The fully qualified ID of the managed application, including the managed + application name and the managed application resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/Microsoft.Solutions/applications/{application-name}. + :type application_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Application, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2021_02_01_preview.models.Application or None + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.Application]] + + + request = build_get_by_id_request( + application_id=application_id, + api_version=api_version, + template_url=self.get_by_id.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('Application', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_by_id.metadata = {'url': "/{applicationId}"} # type: ignore + + + async def _delete_by_id_initial( # pylint: disable=inconsistent-return-statements + self, + application_id: str, + **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_by_id_request_initial( + application_id=application_id, + api_version=api_version, + template_url=self._delete_by_id_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_by_id_initial.metadata = {'url': "/{applicationId}"} # type: ignore + + + @distributed_trace_async + async def begin_delete_by_id( # pylint: disable=inconsistent-return-statements + self, + application_id: str, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes the managed application. + + :param application_id: The fully qualified ID of the managed application, including the managed + application name and the managed application resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/Microsoft.Solutions/applications/{application-name}. + :type application_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._delete_by_id_initial( # type: ignore + application_id=application_id, + api_version=api_version, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete_by_id.metadata = {'url': "/{applicationId}"} # type: ignore + + async def _create_or_update_by_id_initial( + self, + application_id: str, + parameters: _models.Application, + **kwargs: Any + ) -> _models.Application: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Application] + + _json = self._serialize.body(parameters, 'Application') + + request = build_create_or_update_by_id_request_initial( + application_id=application_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._create_or_update_by_id_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('Application', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('Application', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_by_id_initial.metadata = {'url': "/{applicationId}"} # type: ignore + + + @distributed_trace_async + async def begin_create_or_update_by_id( + self, + application_id: str, + parameters: _models.Application, + **kwargs: Any + ) -> AsyncLROPoller[_models.Application]: + """Creates or updates a managed application. + + :param application_id: The fully qualified ID of the managed application, including the managed + application name and the managed application resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/Microsoft.Solutions/applications/{application-name}. + :type application_id: str + :param parameters: Parameters supplied to the create or update a managed application. + :type parameters: ~azure.mgmt.managedapplication.v2021_02_01_preview.models.Application + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either Application or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.managedapplication.v2021_02_01_preview.models.Application] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Application] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._create_or_update_by_id_initial( # type: ignore + application_id=application_id, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('Application', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update_by_id.metadata = {'url': "/{applicationId}"} # type: ignore + + async def _update_by_id_initial( + self, + application_id: str, + parameters: Optional[_models.ApplicationPatchable] = None, + **kwargs: Any + ) -> _models.ApplicationPatchable: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationPatchable] + + if parameters is not None: + _json = self._serialize.body(parameters, 'ApplicationPatchable') + else: + _json = None + + request = build_update_by_id_request_initial( + application_id=application_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._update_by_id_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('ApplicationPatchable', pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize('ApplicationPatchable', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _update_by_id_initial.metadata = {'url': "/{applicationId}"} # type: ignore + + + @distributed_trace_async + async def begin_update_by_id( + self, + application_id: str, + parameters: Optional[_models.ApplicationPatchable] = None, + **kwargs: Any + ) -> AsyncLROPoller[_models.ApplicationPatchable]: + """Updates an existing managed application. + + :param application_id: The fully qualified ID of the managed application, including the managed + application name and the managed application resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/Microsoft.Solutions/applications/{application-name}. + :type application_id: str + :param parameters: Parameters supplied to update an existing managed application. Default value + is None. + :type parameters: + ~azure.mgmt.managedapplication.v2021_02_01_preview.models.ApplicationPatchable + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ApplicationPatchable or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.managedapplication.v2021_02_01_preview.models.ApplicationPatchable] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationPatchable] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._update_by_id_initial( # type: ignore + application_id=application_id, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('ApplicationPatchable', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_update_by_id.metadata = {'url': "/{applicationId}"} # type: ignore + + async def _refresh_permissions_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + application_name: str, + **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_refresh_permissions_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + application_name=application_name, + api_version=api_version, + template_url=self._refresh_permissions_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _refresh_permissions_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}/refreshPermissions"} # type: ignore + + + @distributed_trace_async + async def begin_refresh_permissions( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + application_name: str, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Refresh Permissions for application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_name: The name of the managed application. + :type application_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._refresh_permissions_initial( # type: ignore + resource_group_name=resource_group_name, + application_name=application_name, + api_version=api_version, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'location'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_refresh_permissions.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}/refreshPermissions"} # type: ignore + + @distributed_trace_async + async def list_allowed_upgrade_plans( + self, + resource_group_name: str, + application_name: str, + **kwargs: Any + ) -> _models.AllowedUpgradePlansResult: + """List allowed upgrade plans for application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_name: The name of the managed application. + :type application_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AllowedUpgradePlansResult, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2021_02_01_preview.models.AllowedUpgradePlansResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AllowedUpgradePlansResult] + + + request = build_list_allowed_upgrade_plans_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + application_name=application_name, + api_version=api_version, + template_url=self.list_allowed_upgrade_plans.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('AllowedUpgradePlansResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_allowed_upgrade_plans.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}/listAllowedUpgradePlans"} # type: ignore + + + async def _update_access_initial( + self, + resource_group_name: str, + application_name: str, + parameters: _models.UpdateAccessDefinition, + **kwargs: Any + ) -> Optional[_models.UpdateAccessDefinition]: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.UpdateAccessDefinition]] + + _json = self._serialize.body(parameters, 'UpdateAccessDefinition') + + request = build_update_access_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + application_name=application_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._update_access_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 202: + deserialized = self._deserialize('UpdateAccessDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _update_access_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}/updateAccess"} # type: ignore + + + @distributed_trace_async + async def begin_update_access( + self, + resource_group_name: str, + application_name: str, + parameters: _models.UpdateAccessDefinition, + **kwargs: Any + ) -> AsyncLROPoller[_models.UpdateAccessDefinition]: + """Update access for application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_name: The name of the managed application. + :type application_name: str + :param parameters: Request body parameters to update access. + :type parameters: + ~azure.mgmt.managedapplication.v2021_02_01_preview.models.UpdateAccessDefinition + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either UpdateAccessDefinition or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.managedapplication.v2021_02_01_preview.models.UpdateAccessDefinition] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.UpdateAccessDefinition] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._update_access_initial( # type: ignore + resource_group_name=resource_group_name, + application_name=application_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('UpdateAccessDefinition', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'location'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_update_access.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}/updateAccess"} # type: ignore + + @distributed_trace_async + async def list_tokens( + self, + resource_group_name: str, + application_name: str, + parameters: _models.ListTokenRequest, + **kwargs: Any + ) -> _models.ManagedIdentityTokenResult: + """List tokens for application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_name: The name of the managed application. + :type application_name: str + :param parameters: Request body parameters to list tokens. + :type parameters: ~azure.mgmt.managedapplication.v2021_02_01_preview.models.ListTokenRequest + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ManagedIdentityTokenResult, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2021_02_01_preview.models.ManagedIdentityTokenResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ManagedIdentityTokenResult] + + _json = self._serialize.body(parameters, 'ListTokenRequest') + + request = build_list_tokens_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + application_name=application_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.list_tokens.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ManagedIdentityTokenResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_tokens.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}/listTokens"} # type: ignore + diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_02_01_preview/aio/operations/_jit_requests_operations.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_02_01_preview/aio/operations/_jit_requests_operations.py new file mode 100644 index 000000000000..53e058810cfd --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_02_01_preview/aio/operations/_jit_requests_operations.py @@ -0,0 +1,505 @@ +# 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, Union, cast + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._jit_requests_operations import build_create_or_update_request_initial, build_delete_request, build_get_request, build_list_by_resource_group_request, build_list_by_subscription_request, build_update_request +from .._vendor import MixinABC +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class JitRequestsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.managedapplication.v2021_02_01_preview.aio.ApplicationClient`'s + :attr:`jit_requests` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + jit_request_name: str, + **kwargs: Any + ) -> Optional[_models.JitRequestDefinition]: + """Gets the JIT request. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param jit_request_name: The name of the JIT request. + :type jit_request_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JitRequestDefinition, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2021_02_01_preview.models.JitRequestDefinition or None + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.JitRequestDefinition]] + + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + jit_request_name=jit_request_name, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('JitRequestDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/jitRequests/{jitRequestName}"} # type: ignore + + + async def _create_or_update_initial( + self, + resource_group_name: str, + jit_request_name: str, + parameters: _models.JitRequestDefinition, + **kwargs: Any + ) -> _models.JitRequestDefinition: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.JitRequestDefinition] + + _json = self._serialize.body(parameters, 'JitRequestDefinition') + + request = build_create_or_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + jit_request_name=jit_request_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('JitRequestDefinition', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('JitRequestDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/jitRequests/{jitRequestName}"} # type: ignore + + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + jit_request_name: str, + parameters: _models.JitRequestDefinition, + **kwargs: Any + ) -> AsyncLROPoller[_models.JitRequestDefinition]: + """Creates or updates the JIT request. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param jit_request_name: The name of the JIT request. + :type jit_request_name: str + :param parameters: Parameters supplied to the update JIT request. + :type parameters: + ~azure.mgmt.managedapplication.v2021_02_01_preview.models.JitRequestDefinition + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either JitRequestDefinition or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.managedapplication.v2021_02_01_preview.models.JitRequestDefinition] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.JitRequestDefinition] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._create_or_update_initial( # type: ignore + resource_group_name=resource_group_name, + jit_request_name=jit_request_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('JitRequestDefinition', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/jitRequests/{jitRequestName}"} # type: ignore + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + jit_request_name: str, + parameters: _models.JitRequestPatchable, + **kwargs: Any + ) -> _models.JitRequestDefinition: + """Updates the JIT request. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param jit_request_name: The name of the JIT request. + :type jit_request_name: str + :param parameters: Parameters supplied to the update JIT request. + :type parameters: ~azure.mgmt.managedapplication.v2021_02_01_preview.models.JitRequestPatchable + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JitRequestDefinition, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2021_02_01_preview.models.JitRequestDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.JitRequestDefinition] + + _json = self._serialize.body(parameters, 'JitRequestPatchable') + + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + jit_request_name=jit_request_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('JitRequestDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/jitRequests/{jitRequestName}"} # type: ignore + + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + jit_request_name: str, + **kwargs: Any + ) -> None: + """Deletes the JIT request. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param jit_request_name: The name of the JIT request. + :type jit_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 + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + jit_request_name=jit_request_name, + api_version=api_version, + template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/jitRequests/{jitRequestName}"} # type: ignore + + + @distributed_trace_async + async def list_by_subscription( + self, + **kwargs: Any + ) -> _models.JitRequestDefinitionListResult: + """Lists all JIT requests within the subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JitRequestDefinitionListResult, or the result of cls(response) + :rtype: + ~azure.mgmt.managedapplication.v2021_02_01_preview.models.JitRequestDefinitionListResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.JitRequestDefinitionListResult] + + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('JitRequestDefinitionListResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Solutions/jitRequests"} # type: ignore + + + @distributed_trace_async + async def list_by_resource_group( + self, + resource_group_name: str, + **kwargs: Any + ) -> _models.JitRequestDefinitionListResult: + """Lists all JIT requests within the 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: JitRequestDefinitionListResult, or the result of cls(response) + :rtype: + ~azure.mgmt.managedapplication.v2021_02_01_preview.models.JitRequestDefinitionListResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.JitRequestDefinitionListResult] + + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + api_version=api_version, + template_url=self.list_by_resource_group.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('JitRequestDefinitionListResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/jitRequests"} # type: ignore + diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_02_01_preview/aio/operations/_patch.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_02_01_preview/aio/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_02_01_preview/aio/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_02_01_preview/models/__init__.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_02_01_preview/models/__init__.py new file mode 100644 index 000000000000..3d425edf3ffd --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_02_01_preview/models/__init__.py @@ -0,0 +1,153 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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 AllowedUpgradePlansResult +from ._models_py3 import Application +from ._models_py3 import ApplicationArtifact +from ._models_py3 import ApplicationAuthorization +from ._models_py3 import ApplicationBillingDetailsDefinition +from ._models_py3 import ApplicationClientDetails +from ._models_py3 import ApplicationDefinition +from ._models_py3 import ApplicationDefinitionArtifact +from ._models_py3 import ApplicationDefinitionListResult +from ._models_py3 import ApplicationDefinitionPatchable +from ._models_py3 import ApplicationDeploymentPolicy +from ._models_py3 import ApplicationJitAccessPolicy +from ._models_py3 import ApplicationListResult +from ._models_py3 import ApplicationManagementPolicy +from ._models_py3 import ApplicationNotificationEndpoint +from ._models_py3 import ApplicationNotificationPolicy +from ._models_py3 import ApplicationPackageContact +from ._models_py3 import ApplicationPackageLockingPolicyDefinition +from ._models_py3 import ApplicationPackageSupportUrls +from ._models_py3 import ApplicationPatchable +from ._models_py3 import ApplicationPolicy +from ._models_py3 import ApplicationPropertiesPatchable +from ._models_py3 import ErrorAdditionalInfo +from ._models_py3 import ErrorDetail +from ._models_py3 import ErrorResponse +from ._models_py3 import GenericResource +from ._models_py3 import Identity +from ._models_py3 import JitApproverDefinition +from ._models_py3 import JitAuthorizationPolicies +from ._models_py3 import JitRequestDefinition +from ._models_py3 import JitRequestDefinitionListResult +from ._models_py3 import JitRequestMetadata +from ._models_py3 import JitRequestPatchable +from ._models_py3 import JitSchedulingPolicy +from ._models_py3 import ListTokenRequest +from ._models_py3 import ManagedIdentityToken +from ._models_py3 import ManagedIdentityTokenResult +from ._models_py3 import Operation +from ._models_py3 import OperationAutoGenerated +from ._models_py3 import OperationDisplay +from ._models_py3 import OperationDisplayAutoGenerated +from ._models_py3 import OperationListResult +from ._models_py3 import OperationListResultAutoGenerated +from ._models_py3 import Plan +from ._models_py3 import PlanPatchable +from ._models_py3 import Resource +from ._models_py3 import Sku +from ._models_py3 import SystemData +from ._models_py3 import UpdateAccessDefinition +from ._models_py3 import UserAssignedResourceIdentity + + +from ._application_client_enums import ( + ActionType, + ApplicationArtifactName, + ApplicationArtifactType, + ApplicationDefinitionArtifactName, + ApplicationLockLevel, + ApplicationManagementMode, + CreatedByType, + DeploymentMode, + JitApprovalMode, + JitApproverType, + JitRequestState, + JitSchedulingType, + Origin, + ProvisioningState, + ResourceIdentityType, + Status, + Substatus, +) +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk +__all__ = [ + 'AllowedUpgradePlansResult', + 'Application', + 'ApplicationArtifact', + 'ApplicationAuthorization', + 'ApplicationBillingDetailsDefinition', + 'ApplicationClientDetails', + 'ApplicationDefinition', + 'ApplicationDefinitionArtifact', + 'ApplicationDefinitionListResult', + 'ApplicationDefinitionPatchable', + 'ApplicationDeploymentPolicy', + 'ApplicationJitAccessPolicy', + 'ApplicationListResult', + 'ApplicationManagementPolicy', + 'ApplicationNotificationEndpoint', + 'ApplicationNotificationPolicy', + 'ApplicationPackageContact', + 'ApplicationPackageLockingPolicyDefinition', + 'ApplicationPackageSupportUrls', + 'ApplicationPatchable', + 'ApplicationPolicy', + 'ApplicationPropertiesPatchable', + 'ErrorAdditionalInfo', + 'ErrorDetail', + 'ErrorResponse', + 'GenericResource', + 'Identity', + 'JitApproverDefinition', + 'JitAuthorizationPolicies', + 'JitRequestDefinition', + 'JitRequestDefinitionListResult', + 'JitRequestMetadata', + 'JitRequestPatchable', + 'JitSchedulingPolicy', + 'ListTokenRequest', + 'ManagedIdentityToken', + 'ManagedIdentityTokenResult', + 'Operation', + 'OperationAutoGenerated', + 'OperationDisplay', + 'OperationDisplayAutoGenerated', + 'OperationListResult', + 'OperationListResultAutoGenerated', + 'Plan', + 'PlanPatchable', + 'Resource', + 'Sku', + 'SystemData', + 'UpdateAccessDefinition', + 'UserAssignedResourceIdentity', + 'ActionType', + 'ApplicationArtifactName', + 'ApplicationArtifactType', + 'ApplicationDefinitionArtifactName', + 'ApplicationLockLevel', + 'ApplicationManagementMode', + 'CreatedByType', + 'DeploymentMode', + 'JitApprovalMode', + 'JitApproverType', + 'JitRequestState', + 'JitSchedulingType', + 'Origin', + 'ProvisioningState', + 'ResourceIdentityType', + 'Status', + 'Substatus', +] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_02_01_preview/models/_application_client_enums.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_02_01_preview/models/_application_client_enums.py new file mode 100644 index 000000000000..b56090440331 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_02_01_preview/models/_application_client_enums.py @@ -0,0 +1,166 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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 azure.core import CaseInsensitiveEnumMeta + + +class ActionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. + """ + + INTERNAL = "Internal" + +class ApplicationArtifactName(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The managed application artifact name. + """ + + NOT_SPECIFIED = "NotSpecified" + VIEW_DEFINITION = "ViewDefinition" + AUTHORIZATIONS = "Authorizations" + CUSTOM_ROLE_DEFINITION = "CustomRoleDefinition" + +class ApplicationArtifactType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The managed application artifact type. + """ + + NOT_SPECIFIED = "NotSpecified" + TEMPLATE = "Template" + CUSTOM = "Custom" + +class ApplicationDefinitionArtifactName(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The managed application artifact name. + """ + + NOT_SPECIFIED = "NotSpecified" + APPLICATION_RESOURCE_TEMPLATE = "ApplicationResourceTemplate" + CREATE_UI_DEFINITION = "CreateUiDefinition" + MAIN_TEMPLATE_PARAMETERS = "MainTemplateParameters" + +class ApplicationLockLevel(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The managed application lock level. + """ + + CAN_NOT_DELETE = "CanNotDelete" + READ_ONLY = "ReadOnly" + NONE = "None" + +class ApplicationManagementMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The management mode. + """ + + NOT_SPECIFIED = "NotSpecified" + UNMANAGED = "Unmanaged" + MANAGED = "Managed" + +class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of identity that created the resource. + """ + + USER = "User" + APPLICATION = "Application" + MANAGED_IDENTITY = "ManagedIdentity" + KEY = "Key" + +class DeploymentMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The deployment mode. + """ + + NOT_SPECIFIED = "NotSpecified" + INCREMENTAL = "Incremental" + COMPLETE = "Complete" + +class JitApprovalMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The Jit approval mode. + """ + + NOT_SPECIFIED = "NotSpecified" + AUTO_APPROVE = "AutoApprove" + MANUAL_APPROVE = "ManualApprove" + +class JitApproverType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The approver type. + """ + + USER = "user" + GROUP = "group" + +class JitRequestState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The JIT request state. + """ + + NOT_SPECIFIED = "NotSpecified" + PENDING = "Pending" + APPROVED = "Approved" + DENIED = "Denied" + FAILED = "Failed" + CANCELED = "Canceled" + EXPIRED = "Expired" + TIMEOUT = "Timeout" + +class JitSchedulingType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The JIT request scheduling type. + """ + + NOT_SPECIFIED = "NotSpecified" + ONCE = "Once" + RECURRING = "Recurring" + +class Origin(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit + logs UX. Default value is "user,system" + """ + + USER = "user" + SYSTEM = "system" + USER_SYSTEM = "user,system" + +class ProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Provisioning status of the managed application. + """ + + NOT_SPECIFIED = "NotSpecified" + ACCEPTED = "Accepted" + RUNNING = "Running" + READY = "Ready" + CREATING = "Creating" + CREATED = "Created" + DELETING = "Deleting" + DELETED = "Deleted" + CANCELED = "Canceled" + FAILED = "Failed" + SUCCEEDED = "Succeeded" + UPDATING = "Updating" + +class ResourceIdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The identity type. + """ + + SYSTEM_ASSIGNED = "SystemAssigned" + USER_ASSIGNED = "UserAssigned" + SYSTEM_ASSIGNED_USER_ASSIGNED = "SystemAssigned, UserAssigned" + NONE = "None" + +class Status(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The JIT status. + """ + + NOT_SPECIFIED = "NotSpecified" + ELEVATE = "Elevate" + REMOVE = "Remove" + +class Substatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The sub status. + """ + + NOT_SPECIFIED = "NotSpecified" + APPROVED = "Approved" + DENIED = "Denied" + FAILED = "Failed" + EXPIRED = "Expired" + TIMEOUT = "Timeout" diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_02_01_preview/models/_models_py3.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_02_01_preview/models/_models_py3.py new file mode 100644 index 000000000000..e2104a8eb3ad --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_02_01_preview/models/_models_py3.py @@ -0,0 +1,2699 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for 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 Any, Dict, List, Optional, TYPE_CHECKING, Union + +from azure.core.exceptions import HttpResponseError +import msrest.serialization + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + import __init__ as _models + + +class AllowedUpgradePlansResult(msrest.serialization.Model): + """The array of plan. + + :ivar value: The array of plans. + :vartype value: list[~azure.mgmt.managedapplication.v2021_02_01_preview.models.Plan] + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Plan]'}, + } + + def __init__( + self, + *, + value: Optional[List["_models.Plan"]] = None, + **kwargs + ): + """ + :keyword value: The array of plans. + :paramtype value: list[~azure.mgmt.managedapplication.v2021_02_01_preview.models.Plan] + """ + super(AllowedUpgradePlansResult, self).__init__(**kwargs) + self.value = value + + +class Resource(msrest.serialization.Model): + """Resource information. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Resource ID. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar location: Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~azure.mgmt.managedapplication.v2021_02_01_preview.models.SystemData + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'system_data': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'location': {'key': 'location', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + 'system_data': {'key': 'systemData', 'type': 'SystemData'}, + } + + def __init__( + self, + *, + location: Optional[str] = None, + tags: Optional[Dict[str, str]] = None, + **kwargs + ): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + """ + super(Resource, self).__init__(**kwargs) + self.id = None + self.name = None + self.type = None + self.location = location + self.tags = tags + self.system_data = None + + +class GenericResource(Resource): + """Resource information. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Resource ID. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar location: Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~azure.mgmt.managedapplication.v2021_02_01_preview.models.SystemData + :ivar managed_by: ID of the resource that manages this resource. + :vartype managed_by: str + :ivar sku: The SKU of the resource. + :vartype sku: ~azure.mgmt.managedapplication.v2021_02_01_preview.models.Sku + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'system_data': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'location': {'key': 'location', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + 'system_data': {'key': 'systemData', 'type': 'SystemData'}, + 'managed_by': {'key': 'managedBy', 'type': 'str'}, + 'sku': {'key': 'sku', 'type': 'Sku'}, + } + + def __init__( + self, + *, + location: Optional[str] = None, + tags: Optional[Dict[str, str]] = None, + managed_by: Optional[str] = None, + sku: Optional["_models.Sku"] = None, + **kwargs + ): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword managed_by: ID of the resource that manages this resource. + :paramtype managed_by: str + :keyword sku: The SKU of the resource. + :paramtype sku: ~azure.mgmt.managedapplication.v2021_02_01_preview.models.Sku + """ + super(GenericResource, self).__init__(location=location, tags=tags, **kwargs) + self.managed_by = managed_by + self.sku = sku + + +class Application(GenericResource): + """Information about managed application. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar id: Resource ID. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar location: Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~azure.mgmt.managedapplication.v2021_02_01_preview.models.SystemData + :ivar managed_by: ID of the resource that manages this resource. + :vartype managed_by: str + :ivar sku: The SKU of the resource. + :vartype sku: ~azure.mgmt.managedapplication.v2021_02_01_preview.models.Sku + :ivar plan: The plan information. + :vartype plan: ~azure.mgmt.managedapplication.v2021_02_01_preview.models.Plan + :ivar kind: Required. The kind of the managed application. Allowed values are MarketPlace and + ServiceCatalog. + :vartype kind: str + :ivar identity: The identity of the resource. + :vartype identity: ~azure.mgmt.managedapplication.v2021_02_01_preview.models.Identity + :ivar managed_resource_group_id: The managed resource group Id. + :vartype managed_resource_group_id: str + :ivar application_definition_id: The fully qualified path of managed application definition Id. + :vartype application_definition_id: str + :ivar parameters: Name and value pairs that define the managed application parameters. It can + be a JObject or a well formed JSON string. + :vartype parameters: any + :ivar outputs: Name and value pairs that define the managed application outputs. + :vartype outputs: any + :ivar provisioning_state: The managed application provisioning state. Known values are: + "NotSpecified", "Accepted", "Running", "Ready", "Creating", "Created", "Deleting", "Deleted", + "Canceled", "Failed", "Succeeded", "Updating". + :vartype provisioning_state: str or + ~azure.mgmt.managedapplication.v2021_02_01_preview.models.ProvisioningState + :ivar billing_details: The managed application billing details. + :vartype billing_details: + ~azure.mgmt.managedapplication.v2021_02_01_preview.models.ApplicationBillingDetailsDefinition + :ivar jit_access_policy: The managed application Jit access policy. + :vartype jit_access_policy: + ~azure.mgmt.managedapplication.v2021_02_01_preview.models.ApplicationJitAccessPolicy + :ivar publisher_tenant_id: The publisher tenant Id. + :vartype publisher_tenant_id: str + :ivar authorizations: The read-only authorizations property that is retrieved from the + application package. + :vartype authorizations: + list[~azure.mgmt.managedapplication.v2021_02_01_preview.models.ApplicationAuthorization] + :ivar management_mode: The managed application management mode. Known values are: + "NotSpecified", "Unmanaged", "Managed". + :vartype management_mode: str or + ~azure.mgmt.managedapplication.v2021_02_01_preview.models.ApplicationManagementMode + :ivar customer_support: The read-only customer support property that is retrieved from the + application package. + :vartype customer_support: + ~azure.mgmt.managedapplication.v2021_02_01_preview.models.ApplicationPackageContact + :ivar support_urls: The read-only support URLs property that is retrieved from the application + package. + :vartype support_urls: + ~azure.mgmt.managedapplication.v2021_02_01_preview.models.ApplicationPackageSupportUrls + :ivar artifacts: The collection of managed application artifacts. + :vartype artifacts: + list[~azure.mgmt.managedapplication.v2021_02_01_preview.models.ApplicationArtifact] + :ivar created_by: The client entity that created the JIT request. + :vartype created_by: + ~azure.mgmt.managedapplication.v2021_02_01_preview.models.ApplicationClientDetails + :ivar updated_by: The client entity that last updated the JIT request. + :vartype updated_by: + ~azure.mgmt.managedapplication.v2021_02_01_preview.models.ApplicationClientDetails + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'system_data': {'readonly': True}, + 'kind': {'required': True, 'pattern': r'^[-\w\._,\(\)]+$'}, + 'outputs': {'readonly': True}, + 'provisioning_state': {'readonly': True}, + 'billing_details': {'readonly': True}, + 'publisher_tenant_id': {'readonly': True}, + 'authorizations': {'readonly': True}, + 'management_mode': {'readonly': True}, + 'customer_support': {'readonly': True}, + 'support_urls': {'readonly': True}, + 'artifacts': {'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'}, + 'location': {'key': 'location', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + 'system_data': {'key': 'systemData', 'type': 'SystemData'}, + 'managed_by': {'key': 'managedBy', 'type': 'str'}, + 'sku': {'key': 'sku', 'type': 'Sku'}, + 'plan': {'key': 'plan', 'type': 'Plan'}, + 'kind': {'key': 'kind', 'type': 'str'}, + 'identity': {'key': 'identity', 'type': 'Identity'}, + 'managed_resource_group_id': {'key': 'properties.managedResourceGroupId', 'type': 'str'}, + 'application_definition_id': {'key': 'properties.applicationDefinitionId', 'type': 'str'}, + 'parameters': {'key': 'properties.parameters', 'type': 'object'}, + 'outputs': {'key': 'properties.outputs', 'type': 'object'}, + 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + 'billing_details': {'key': 'properties.billingDetails', 'type': 'ApplicationBillingDetailsDefinition'}, + 'jit_access_policy': {'key': 'properties.jitAccessPolicy', 'type': 'ApplicationJitAccessPolicy'}, + 'publisher_tenant_id': {'key': 'properties.publisherTenantId', 'type': 'str'}, + 'authorizations': {'key': 'properties.authorizations', 'type': '[ApplicationAuthorization]'}, + 'management_mode': {'key': 'properties.managementMode', 'type': 'str'}, + 'customer_support': {'key': 'properties.customerSupport', 'type': 'ApplicationPackageContact'}, + 'support_urls': {'key': 'properties.supportUrls', 'type': 'ApplicationPackageSupportUrls'}, + 'artifacts': {'key': 'properties.artifacts', 'type': '[ApplicationArtifact]'}, + 'created_by': {'key': 'properties.createdBy', 'type': 'ApplicationClientDetails'}, + 'updated_by': {'key': 'properties.updatedBy', 'type': 'ApplicationClientDetails'}, + } + + def __init__( + self, + *, + kind: str, + location: Optional[str] = None, + tags: Optional[Dict[str, str]] = None, + managed_by: Optional[str] = None, + sku: Optional["_models.Sku"] = None, + plan: Optional["_models.Plan"] = None, + identity: Optional["_models.Identity"] = None, + managed_resource_group_id: Optional[str] = None, + application_definition_id: Optional[str] = None, + parameters: Optional[Any] = None, + jit_access_policy: Optional["_models.ApplicationJitAccessPolicy"] = None, + **kwargs + ): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword managed_by: ID of the resource that manages this resource. + :paramtype managed_by: str + :keyword sku: The SKU of the resource. + :paramtype sku: ~azure.mgmt.managedapplication.v2021_02_01_preview.models.Sku + :keyword plan: The plan information. + :paramtype plan: ~azure.mgmt.managedapplication.v2021_02_01_preview.models.Plan + :keyword kind: Required. The kind of the managed application. Allowed values are MarketPlace + and ServiceCatalog. + :paramtype kind: str + :keyword identity: The identity of the resource. + :paramtype identity: ~azure.mgmt.managedapplication.v2021_02_01_preview.models.Identity + :keyword managed_resource_group_id: The managed resource group Id. + :paramtype managed_resource_group_id: str + :keyword application_definition_id: The fully qualified path of managed application definition + Id. + :paramtype application_definition_id: str + :keyword parameters: Name and value pairs that define the managed application parameters. It + can be a JObject or a well formed JSON string. + :paramtype parameters: any + :keyword jit_access_policy: The managed application Jit access policy. + :paramtype jit_access_policy: + ~azure.mgmt.managedapplication.v2021_02_01_preview.models.ApplicationJitAccessPolicy + """ + super(Application, self).__init__(location=location, tags=tags, managed_by=managed_by, sku=sku, **kwargs) + self.plan = plan + self.kind = kind + self.identity = identity + self.managed_resource_group_id = managed_resource_group_id + self.application_definition_id = application_definition_id + self.parameters = parameters + self.outputs = None + self.provisioning_state = None + self.billing_details = None + self.jit_access_policy = jit_access_policy + self.publisher_tenant_id = None + self.authorizations = None + self.management_mode = None + self.customer_support = None + self.support_urls = None + self.artifacts = None + self.created_by = None + self.updated_by = None + + +class ApplicationArtifact(msrest.serialization.Model): + """Managed application artifact. + + All required parameters must be populated in order to send to Azure. + + :ivar name: Required. The managed application artifact name. Known values are: "NotSpecified", + "ViewDefinition", "Authorizations", "CustomRoleDefinition". + :vartype name: str or + ~azure.mgmt.managedapplication.v2021_02_01_preview.models.ApplicationArtifactName + :ivar uri: Required. The managed application artifact blob uri. + :vartype uri: str + :ivar type: Required. The managed application artifact type. Known values are: "NotSpecified", + "Template", "Custom". + :vartype type: str or + ~azure.mgmt.managedapplication.v2021_02_01_preview.models.ApplicationArtifactType + """ + + _validation = { + 'name': {'required': True}, + 'uri': {'required': True}, + 'type': {'required': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'uri': {'key': 'uri', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + } + + def __init__( + self, + *, + name: Union[str, "_models.ApplicationArtifactName"], + uri: str, + type: Union[str, "_models.ApplicationArtifactType"], + **kwargs + ): + """ + :keyword name: Required. The managed application artifact name. Known values are: + "NotSpecified", "ViewDefinition", "Authorizations", "CustomRoleDefinition". + :paramtype name: str or + ~azure.mgmt.managedapplication.v2021_02_01_preview.models.ApplicationArtifactName + :keyword uri: Required. The managed application artifact blob uri. + :paramtype uri: str + :keyword type: Required. The managed application artifact type. Known values are: + "NotSpecified", "Template", "Custom". + :paramtype type: str or + ~azure.mgmt.managedapplication.v2021_02_01_preview.models.ApplicationArtifactType + """ + super(ApplicationArtifact, self).__init__(**kwargs) + self.name = name + self.uri = uri + self.type = type + + +class ApplicationAuthorization(msrest.serialization.Model): + """The managed application provider authorization. + + All required parameters must be populated in order to send to Azure. + + :ivar principal_id: Required. The provider's principal identifier. This is the identity that + the provider will use to call ARM to manage the managed application resources. + :vartype principal_id: str + :ivar role_definition_id: Required. The provider's role definition identifier. This role will + define all the permissions that the provider must have on the managed application's container + resource group. This role definition cannot have permission to delete the resource group. + :vartype role_definition_id: str + """ + + _validation = { + 'principal_id': {'required': True}, + 'role_definition_id': {'required': True}, + } + + _attribute_map = { + 'principal_id': {'key': 'principalId', 'type': 'str'}, + 'role_definition_id': {'key': 'roleDefinitionId', 'type': 'str'}, + } + + def __init__( + self, + *, + principal_id: str, + role_definition_id: str, + **kwargs + ): + """ + :keyword principal_id: Required. The provider's principal identifier. This is the identity that + the provider will use to call ARM to manage the managed application resources. + :paramtype principal_id: str + :keyword role_definition_id: Required. The provider's role definition identifier. This role + will define all the permissions that the provider must have on the managed application's + container resource group. This role definition cannot have permission to delete the resource + group. + :paramtype role_definition_id: str + """ + super(ApplicationAuthorization, self).__init__(**kwargs) + self.principal_id = principal_id + self.role_definition_id = role_definition_id + + +class ApplicationBillingDetailsDefinition(msrest.serialization.Model): + """Managed application billing details definition. + + :ivar resource_usage_id: The managed application resource usage Id. + :vartype resource_usage_id: str + """ + + _attribute_map = { + 'resource_usage_id': {'key': 'resourceUsageId', 'type': 'str'}, + } + + def __init__( + self, + *, + resource_usage_id: Optional[str] = None, + **kwargs + ): + """ + :keyword resource_usage_id: The managed application resource usage Id. + :paramtype resource_usage_id: str + """ + super(ApplicationBillingDetailsDefinition, self).__init__(**kwargs) + self.resource_usage_id = resource_usage_id + + +class ApplicationClientDetails(msrest.serialization.Model): + """The application client details to track the entity creating/updating the managed app resource. + + :ivar oid: The client Oid. + :vartype oid: str + :ivar puid: The client Puid. + :vartype puid: str + :ivar application_id: The client application Id. + :vartype application_id: str + """ + + _attribute_map = { + 'oid': {'key': 'oid', 'type': 'str'}, + 'puid': {'key': 'puid', 'type': 'str'}, + 'application_id': {'key': 'applicationId', 'type': 'str'}, + } + + def __init__( + self, + *, + oid: Optional[str] = None, + puid: Optional[str] = None, + application_id: Optional[str] = None, + **kwargs + ): + """ + :keyword oid: The client Oid. + :paramtype oid: str + :keyword puid: The client Puid. + :paramtype puid: str + :keyword application_id: The client application Id. + :paramtype application_id: str + """ + super(ApplicationClientDetails, self).__init__(**kwargs) + self.oid = oid + self.puid = puid + self.application_id = application_id + + +class ApplicationDefinition(GenericResource): + """Information about managed application definition. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar id: Resource ID. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar location: Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~azure.mgmt.managedapplication.v2021_02_01_preview.models.SystemData + :ivar managed_by: ID of the resource that manages this resource. + :vartype managed_by: str + :ivar sku: The SKU of the resource. + :vartype sku: ~azure.mgmt.managedapplication.v2021_02_01_preview.models.Sku + :ivar lock_level: Required. The managed application lock level. Known values are: + "CanNotDelete", "ReadOnly", "None". + :vartype lock_level: str or + ~azure.mgmt.managedapplication.v2021_02_01_preview.models.ApplicationLockLevel + :ivar display_name: The managed application definition display name. + :vartype display_name: str + :ivar is_enabled: A value indicating whether the package is enabled or not. + :vartype is_enabled: bool + :ivar authorizations: The managed application provider authorizations. + :vartype authorizations: + list[~azure.mgmt.managedapplication.v2021_02_01_preview.models.ApplicationAuthorization] + :ivar artifacts: The collection of managed application artifacts. The portal will use the files + specified as artifacts to construct the user experience of creating a managed application from + a managed application definition. + :vartype artifacts: + list[~azure.mgmt.managedapplication.v2021_02_01_preview.models.ApplicationDefinitionArtifact] + :ivar description: The managed application definition description. + :vartype description: str + :ivar package_file_uri: The managed application definition package file Uri. Use this element. + :vartype package_file_uri: str + :ivar storage_account_id: The storage account id for bring your own storage scenario. + :vartype storage_account_id: str + :ivar main_template: The inline main template json which has resources to be provisioned. It + can be a JObject or well-formed JSON string. + :vartype main_template: any + :ivar create_ui_definition: The createUiDefinition json for the backing template with + Microsoft.Solutions/applications resource. It can be a JObject or well-formed JSON string. + :vartype create_ui_definition: any + :ivar notification_policy: The managed application notification policy. + :vartype notification_policy: + ~azure.mgmt.managedapplication.v2021_02_01_preview.models.ApplicationNotificationPolicy + :ivar locking_policy: The managed application locking policy. + :vartype locking_policy: + ~azure.mgmt.managedapplication.v2021_02_01_preview.models.ApplicationPackageLockingPolicyDefinition + :ivar deployment_policy: The managed application deployment policy. + :vartype deployment_policy: + ~azure.mgmt.managedapplication.v2021_02_01_preview.models.ApplicationDeploymentPolicy + :ivar management_policy: The managed application management policy that determines publisher's + access to the managed resource group. + :vartype management_policy: + ~azure.mgmt.managedapplication.v2021_02_01_preview.models.ApplicationManagementPolicy + :ivar policies: The managed application provider policies. + :vartype policies: + list[~azure.mgmt.managedapplication.v2021_02_01_preview.models.ApplicationPolicy] + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'system_data': {'readonly': True}, + 'lock_level': {'required': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'location': {'key': 'location', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + 'system_data': {'key': 'systemData', 'type': 'SystemData'}, + 'managed_by': {'key': 'managedBy', 'type': 'str'}, + 'sku': {'key': 'sku', 'type': 'Sku'}, + 'lock_level': {'key': 'properties.lockLevel', 'type': 'str'}, + 'display_name': {'key': 'properties.displayName', 'type': 'str'}, + 'is_enabled': {'key': 'properties.isEnabled', 'type': 'bool'}, + 'authorizations': {'key': 'properties.authorizations', 'type': '[ApplicationAuthorization]'}, + 'artifacts': {'key': 'properties.artifacts', 'type': '[ApplicationDefinitionArtifact]'}, + 'description': {'key': 'properties.description', 'type': 'str'}, + 'package_file_uri': {'key': 'properties.packageFileUri', 'type': 'str'}, + 'storage_account_id': {'key': 'properties.storageAccountId', 'type': 'str'}, + 'main_template': {'key': 'properties.mainTemplate', 'type': 'object'}, + 'create_ui_definition': {'key': 'properties.createUiDefinition', 'type': 'object'}, + 'notification_policy': {'key': 'properties.notificationPolicy', 'type': 'ApplicationNotificationPolicy'}, + 'locking_policy': {'key': 'properties.lockingPolicy', 'type': 'ApplicationPackageLockingPolicyDefinition'}, + 'deployment_policy': {'key': 'properties.deploymentPolicy', 'type': 'ApplicationDeploymentPolicy'}, + 'management_policy': {'key': 'properties.managementPolicy', 'type': 'ApplicationManagementPolicy'}, + 'policies': {'key': 'properties.policies', 'type': '[ApplicationPolicy]'}, + } + + def __init__( + self, + *, + lock_level: Union[str, "_models.ApplicationLockLevel"], + location: Optional[str] = None, + tags: Optional[Dict[str, str]] = None, + managed_by: Optional[str] = None, + sku: Optional["_models.Sku"] = None, + display_name: Optional[str] = None, + is_enabled: Optional[bool] = None, + authorizations: Optional[List["_models.ApplicationAuthorization"]] = None, + artifacts: Optional[List["_models.ApplicationDefinitionArtifact"]] = None, + description: Optional[str] = None, + package_file_uri: Optional[str] = None, + storage_account_id: Optional[str] = None, + main_template: Optional[Any] = None, + create_ui_definition: Optional[Any] = None, + notification_policy: Optional["_models.ApplicationNotificationPolicy"] = None, + locking_policy: Optional["_models.ApplicationPackageLockingPolicyDefinition"] = None, + deployment_policy: Optional["_models.ApplicationDeploymentPolicy"] = None, + management_policy: Optional["_models.ApplicationManagementPolicy"] = None, + policies: Optional[List["_models.ApplicationPolicy"]] = None, + **kwargs + ): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword managed_by: ID of the resource that manages this resource. + :paramtype managed_by: str + :keyword sku: The SKU of the resource. + :paramtype sku: ~azure.mgmt.managedapplication.v2021_02_01_preview.models.Sku + :keyword lock_level: Required. The managed application lock level. Known values are: + "CanNotDelete", "ReadOnly", "None". + :paramtype lock_level: str or + ~azure.mgmt.managedapplication.v2021_02_01_preview.models.ApplicationLockLevel + :keyword display_name: The managed application definition display name. + :paramtype display_name: str + :keyword is_enabled: A value indicating whether the package is enabled or not. + :paramtype is_enabled: bool + :keyword authorizations: The managed application provider authorizations. + :paramtype authorizations: + list[~azure.mgmt.managedapplication.v2021_02_01_preview.models.ApplicationAuthorization] + :keyword artifacts: The collection of managed application artifacts. The portal will use the + files specified as artifacts to construct the user experience of creating a managed application + from a managed application definition. + :paramtype artifacts: + list[~azure.mgmt.managedapplication.v2021_02_01_preview.models.ApplicationDefinitionArtifact] + :keyword description: The managed application definition description. + :paramtype description: str + :keyword package_file_uri: The managed application definition package file Uri. Use this + element. + :paramtype package_file_uri: str + :keyword storage_account_id: The storage account id for bring your own storage scenario. + :paramtype storage_account_id: str + :keyword main_template: The inline main template json which has resources to be provisioned. It + can be a JObject or well-formed JSON string. + :paramtype main_template: any + :keyword create_ui_definition: The createUiDefinition json for the backing template with + Microsoft.Solutions/applications resource. It can be a JObject or well-formed JSON string. + :paramtype create_ui_definition: any + :keyword notification_policy: The managed application notification policy. + :paramtype notification_policy: + ~azure.mgmt.managedapplication.v2021_02_01_preview.models.ApplicationNotificationPolicy + :keyword locking_policy: The managed application locking policy. + :paramtype locking_policy: + ~azure.mgmt.managedapplication.v2021_02_01_preview.models.ApplicationPackageLockingPolicyDefinition + :keyword deployment_policy: The managed application deployment policy. + :paramtype deployment_policy: + ~azure.mgmt.managedapplication.v2021_02_01_preview.models.ApplicationDeploymentPolicy + :keyword management_policy: The managed application management policy that determines + publisher's access to the managed resource group. + :paramtype management_policy: + ~azure.mgmt.managedapplication.v2021_02_01_preview.models.ApplicationManagementPolicy + :keyword policies: The managed application provider policies. + :paramtype policies: + list[~azure.mgmt.managedapplication.v2021_02_01_preview.models.ApplicationPolicy] + """ + super(ApplicationDefinition, self).__init__(location=location, tags=tags, managed_by=managed_by, sku=sku, **kwargs) + self.lock_level = lock_level + self.display_name = display_name + self.is_enabled = is_enabled + self.authorizations = authorizations + self.artifacts = artifacts + self.description = description + self.package_file_uri = package_file_uri + self.storage_account_id = storage_account_id + self.main_template = main_template + self.create_ui_definition = create_ui_definition + self.notification_policy = notification_policy + self.locking_policy = locking_policy + self.deployment_policy = deployment_policy + self.management_policy = management_policy + self.policies = policies + + +class ApplicationDefinitionArtifact(msrest.serialization.Model): + """Application definition artifact. + + All required parameters must be populated in order to send to Azure. + + :ivar name: Required. The managed application definition artifact name. Known values are: + "NotSpecified", "ApplicationResourceTemplate", "CreateUiDefinition", "MainTemplateParameters". + :vartype name: str or + ~azure.mgmt.managedapplication.v2021_02_01_preview.models.ApplicationDefinitionArtifactName + :ivar uri: Required. The managed application definition artifact blob uri. + :vartype uri: str + :ivar type: Required. The managed application definition artifact type. Known values are: + "NotSpecified", "Template", "Custom". + :vartype type: str or + ~azure.mgmt.managedapplication.v2021_02_01_preview.models.ApplicationArtifactType + """ + + _validation = { + 'name': {'required': True}, + 'uri': {'required': True}, + 'type': {'required': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'uri': {'key': 'uri', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + } + + def __init__( + self, + *, + name: Union[str, "_models.ApplicationDefinitionArtifactName"], + uri: str, + type: Union[str, "_models.ApplicationArtifactType"], + **kwargs + ): + """ + :keyword name: Required. The managed application definition artifact name. Known values are: + "NotSpecified", "ApplicationResourceTemplate", "CreateUiDefinition", "MainTemplateParameters". + :paramtype name: str or + ~azure.mgmt.managedapplication.v2021_02_01_preview.models.ApplicationDefinitionArtifactName + :keyword uri: Required. The managed application definition artifact blob uri. + :paramtype uri: str + :keyword type: Required. The managed application definition artifact type. Known values are: + "NotSpecified", "Template", "Custom". + :paramtype type: str or + ~azure.mgmt.managedapplication.v2021_02_01_preview.models.ApplicationArtifactType + """ + super(ApplicationDefinitionArtifact, self).__init__(**kwargs) + self.name = name + self.uri = uri + self.type = type + + +class ApplicationDefinitionListResult(msrest.serialization.Model): + """List of managed application definitions. + + :ivar value: The array of managed application definitions. + :vartype value: + list[~azure.mgmt.managedapplication.v2021_02_01_preview.models.ApplicationDefinition] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[ApplicationDefinition]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["_models.ApplicationDefinition"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + """ + :keyword value: The array of managed application definitions. + :paramtype value: + list[~azure.mgmt.managedapplication.v2021_02_01_preview.models.ApplicationDefinition] + :keyword next_link: The URL to use for getting the next set of results. + :paramtype next_link: str + """ + super(ApplicationDefinitionListResult, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class ApplicationDefinitionPatchable(msrest.serialization.Model): + """Information about an application definition request. + + :ivar tags: A set of tags. Application definition tags. + :vartype tags: dict[str, str] + """ + + _attribute_map = { + 'tags': {'key': 'tags', 'type': '{str}'}, + } + + def __init__( + self, + *, + tags: Optional[Dict[str, str]] = None, + **kwargs + ): + """ + :keyword tags: A set of tags. Application definition tags. + :paramtype tags: dict[str, str] + """ + super(ApplicationDefinitionPatchable, self).__init__(**kwargs) + self.tags = tags + + +class ApplicationDeploymentPolicy(msrest.serialization.Model): + """Managed application deployment policy. + + All required parameters must be populated in order to send to Azure. + + :ivar deployment_mode: Required. The managed application deployment mode. Known values are: + "NotSpecified", "Incremental", "Complete". + :vartype deployment_mode: str or + ~azure.mgmt.managedapplication.v2021_02_01_preview.models.DeploymentMode + """ + + _validation = { + 'deployment_mode': {'required': True}, + } + + _attribute_map = { + 'deployment_mode': {'key': 'deploymentMode', 'type': 'str'}, + } + + def __init__( + self, + *, + deployment_mode: Union[str, "_models.DeploymentMode"], + **kwargs + ): + """ + :keyword deployment_mode: Required. The managed application deployment mode. Known values are: + "NotSpecified", "Incremental", "Complete". + :paramtype deployment_mode: str or + ~azure.mgmt.managedapplication.v2021_02_01_preview.models.DeploymentMode + """ + super(ApplicationDeploymentPolicy, self).__init__(**kwargs) + self.deployment_mode = deployment_mode + + +class ApplicationJitAccessPolicy(msrest.serialization.Model): + """Managed application Jit access policy. + + All required parameters must be populated in order to send to Azure. + + :ivar jit_access_enabled: Required. Whether the JIT access is enabled. + :vartype jit_access_enabled: bool + :ivar jit_approval_mode: JIT approval mode. Known values are: "NotSpecified", "AutoApprove", + "ManualApprove". + :vartype jit_approval_mode: str or + ~azure.mgmt.managedapplication.v2021_02_01_preview.models.JitApprovalMode + :ivar jit_approvers: The JIT approvers. + :vartype jit_approvers: + list[~azure.mgmt.managedapplication.v2021_02_01_preview.models.JitApproverDefinition] + :ivar maximum_jit_access_duration: The maximum duration JIT access is granted. This is an + ISO8601 time period value. + :vartype maximum_jit_access_duration: str + """ + + _validation = { + 'jit_access_enabled': {'required': True}, + } + + _attribute_map = { + 'jit_access_enabled': {'key': 'jitAccessEnabled', 'type': 'bool'}, + 'jit_approval_mode': {'key': 'jitApprovalMode', 'type': 'str'}, + 'jit_approvers': {'key': 'jitApprovers', 'type': '[JitApproverDefinition]'}, + 'maximum_jit_access_duration': {'key': 'maximumJitAccessDuration', 'type': 'str'}, + } + + def __init__( + self, + *, + jit_access_enabled: bool, + jit_approval_mode: Optional[Union[str, "_models.JitApprovalMode"]] = None, + jit_approvers: Optional[List["_models.JitApproverDefinition"]] = None, + maximum_jit_access_duration: Optional[str] = None, + **kwargs + ): + """ + :keyword jit_access_enabled: Required. Whether the JIT access is enabled. + :paramtype jit_access_enabled: bool + :keyword jit_approval_mode: JIT approval mode. Known values are: "NotSpecified", "AutoApprove", + "ManualApprove". + :paramtype jit_approval_mode: str or + ~azure.mgmt.managedapplication.v2021_02_01_preview.models.JitApprovalMode + :keyword jit_approvers: The JIT approvers. + :paramtype jit_approvers: + list[~azure.mgmt.managedapplication.v2021_02_01_preview.models.JitApproverDefinition] + :keyword maximum_jit_access_duration: The maximum duration JIT access is granted. This is an + ISO8601 time period value. + :paramtype maximum_jit_access_duration: str + """ + super(ApplicationJitAccessPolicy, self).__init__(**kwargs) + self.jit_access_enabled = jit_access_enabled + self.jit_approval_mode = jit_approval_mode + self.jit_approvers = jit_approvers + self.maximum_jit_access_duration = maximum_jit_access_duration + + +class ApplicationListResult(msrest.serialization.Model): + """List of managed applications. + + :ivar value: The array of managed applications. + :vartype value: list[~azure.mgmt.managedapplication.v2021_02_01_preview.models.Application] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Application]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["_models.Application"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + """ + :keyword value: The array of managed applications. + :paramtype value: list[~azure.mgmt.managedapplication.v2021_02_01_preview.models.Application] + :keyword next_link: The URL to use for getting the next set of results. + :paramtype next_link: str + """ + super(ApplicationListResult, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class ApplicationManagementPolicy(msrest.serialization.Model): + """Managed application management policy. + + :ivar mode: The managed application management mode. Known values are: "NotSpecified", + "Unmanaged", "Managed". + :vartype mode: str or + ~azure.mgmt.managedapplication.v2021_02_01_preview.models.ApplicationManagementMode + """ + + _attribute_map = { + 'mode': {'key': 'mode', 'type': 'str'}, + } + + def __init__( + self, + *, + mode: Optional[Union[str, "_models.ApplicationManagementMode"]] = None, + **kwargs + ): + """ + :keyword mode: The managed application management mode. Known values are: "NotSpecified", + "Unmanaged", "Managed". + :paramtype mode: str or + ~azure.mgmt.managedapplication.v2021_02_01_preview.models.ApplicationManagementMode + """ + super(ApplicationManagementPolicy, self).__init__(**kwargs) + self.mode = mode + + +class ApplicationNotificationEndpoint(msrest.serialization.Model): + """Managed application notification endpoint. + + All required parameters must be populated in order to send to Azure. + + :ivar uri: Required. The managed application notification endpoint uri. + :vartype uri: str + """ + + _validation = { + 'uri': {'required': True}, + } + + _attribute_map = { + 'uri': {'key': 'uri', 'type': 'str'}, + } + + def __init__( + self, + *, + uri: str, + **kwargs + ): + """ + :keyword uri: Required. The managed application notification endpoint uri. + :paramtype uri: str + """ + super(ApplicationNotificationEndpoint, self).__init__(**kwargs) + self.uri = uri + + +class ApplicationNotificationPolicy(msrest.serialization.Model): + """Managed application notification policy. + + All required parameters must be populated in order to send to Azure. + + :ivar notification_endpoints: Required. The managed application notification endpoint. + :vartype notification_endpoints: + list[~azure.mgmt.managedapplication.v2021_02_01_preview.models.ApplicationNotificationEndpoint] + """ + + _validation = { + 'notification_endpoints': {'required': True}, + } + + _attribute_map = { + 'notification_endpoints': {'key': 'notificationEndpoints', 'type': '[ApplicationNotificationEndpoint]'}, + } + + def __init__( + self, + *, + notification_endpoints: List["_models.ApplicationNotificationEndpoint"], + **kwargs + ): + """ + :keyword notification_endpoints: Required. The managed application notification endpoint. + :paramtype notification_endpoints: + list[~azure.mgmt.managedapplication.v2021_02_01_preview.models.ApplicationNotificationEndpoint] + """ + super(ApplicationNotificationPolicy, self).__init__(**kwargs) + self.notification_endpoints = notification_endpoints + + +class ApplicationPackageContact(msrest.serialization.Model): + """The application package contact information. + + All required parameters must be populated in order to send to Azure. + + :ivar contact_name: The contact name. + :vartype contact_name: str + :ivar email: Required. The contact email. + :vartype email: str + :ivar phone: Required. The contact phone number. + :vartype phone: str + """ + + _validation = { + 'email': {'required': True}, + 'phone': {'required': True}, + } + + _attribute_map = { + 'contact_name': {'key': 'contactName', 'type': 'str'}, + 'email': {'key': 'email', 'type': 'str'}, + 'phone': {'key': 'phone', 'type': 'str'}, + } + + def __init__( + self, + *, + email: str, + phone: str, + contact_name: Optional[str] = None, + **kwargs + ): + """ + :keyword contact_name: The contact name. + :paramtype contact_name: str + :keyword email: Required. The contact email. + :paramtype email: str + :keyword phone: Required. The contact phone number. + :paramtype phone: str + """ + super(ApplicationPackageContact, self).__init__(**kwargs) + self.contact_name = contact_name + self.email = email + self.phone = phone + + +class ApplicationPackageLockingPolicyDefinition(msrest.serialization.Model): + """Managed application locking policy. + + :ivar allowed_actions: The deny assignment excluded actions. + :vartype allowed_actions: list[str] + :ivar allowed_data_actions: The deny assignment excluded data actions. + :vartype allowed_data_actions: list[str] + """ + + _attribute_map = { + 'allowed_actions': {'key': 'allowedActions', 'type': '[str]'}, + 'allowed_data_actions': {'key': 'allowedDataActions', 'type': '[str]'}, + } + + def __init__( + self, + *, + allowed_actions: Optional[List[str]] = None, + allowed_data_actions: Optional[List[str]] = None, + **kwargs + ): + """ + :keyword allowed_actions: The deny assignment excluded actions. + :paramtype allowed_actions: list[str] + :keyword allowed_data_actions: The deny assignment excluded data actions. + :paramtype allowed_data_actions: list[str] + """ + super(ApplicationPackageLockingPolicyDefinition, self).__init__(**kwargs) + self.allowed_actions = allowed_actions + self.allowed_data_actions = allowed_data_actions + + +class ApplicationPackageSupportUrls(msrest.serialization.Model): + """The appliance package support URLs. + + :ivar public_azure: The public azure support URL. + :vartype public_azure: str + :ivar government_cloud: The government cloud support URL. + :vartype government_cloud: str + """ + + _attribute_map = { + 'public_azure': {'key': 'publicAzure', 'type': 'str'}, + 'government_cloud': {'key': 'governmentCloud', 'type': 'str'}, + } + + def __init__( + self, + *, + public_azure: Optional[str] = None, + government_cloud: Optional[str] = None, + **kwargs + ): + """ + :keyword public_azure: The public azure support URL. + :paramtype public_azure: str + :keyword government_cloud: The government cloud support URL. + :paramtype government_cloud: str + """ + super(ApplicationPackageSupportUrls, self).__init__(**kwargs) + self.public_azure = public_azure + self.government_cloud = government_cloud + + +class ApplicationPatchable(GenericResource): + """Information about managed application. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Resource ID. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar location: Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~azure.mgmt.managedapplication.v2021_02_01_preview.models.SystemData + :ivar managed_by: ID of the resource that manages this resource. + :vartype managed_by: str + :ivar sku: The SKU of the resource. + :vartype sku: ~azure.mgmt.managedapplication.v2021_02_01_preview.models.Sku + :ivar plan: The plan information. + :vartype plan: ~azure.mgmt.managedapplication.v2021_02_01_preview.models.PlanPatchable + :ivar kind: The kind of the managed application. Allowed values are MarketPlace and + ServiceCatalog. + :vartype kind: str + :ivar identity: The identity of the resource. + :vartype identity: ~azure.mgmt.managedapplication.v2021_02_01_preview.models.Identity + :ivar managed_resource_group_id: The managed resource group Id. + :vartype managed_resource_group_id: str + :ivar application_definition_id: The fully qualified path of managed application definition Id. + :vartype application_definition_id: str + :ivar parameters: Name and value pairs that define the managed application parameters. It can + be a JObject or a well formed JSON string. + :vartype parameters: any + :ivar outputs: Name and value pairs that define the managed application outputs. + :vartype outputs: any + :ivar provisioning_state: The managed application provisioning state. Known values are: + "NotSpecified", "Accepted", "Running", "Ready", "Creating", "Created", "Deleting", "Deleted", + "Canceled", "Failed", "Succeeded", "Updating". + :vartype provisioning_state: str or + ~azure.mgmt.managedapplication.v2021_02_01_preview.models.ProvisioningState + :ivar billing_details: The managed application billing details. + :vartype billing_details: + ~azure.mgmt.managedapplication.v2021_02_01_preview.models.ApplicationBillingDetailsDefinition + :ivar jit_access_policy: The managed application Jit access policy. + :vartype jit_access_policy: + ~azure.mgmt.managedapplication.v2021_02_01_preview.models.ApplicationJitAccessPolicy + :ivar publisher_tenant_id: The publisher tenant Id. + :vartype publisher_tenant_id: str + :ivar authorizations: The read-only authorizations property that is retrieved from the + application package. + :vartype authorizations: + list[~azure.mgmt.managedapplication.v2021_02_01_preview.models.ApplicationAuthorization] + :ivar management_mode: The managed application management mode. Known values are: + "NotSpecified", "Unmanaged", "Managed". + :vartype management_mode: str or + ~azure.mgmt.managedapplication.v2021_02_01_preview.models.ApplicationManagementMode + :ivar customer_support: The read-only customer support property that is retrieved from the + application package. + :vartype customer_support: + ~azure.mgmt.managedapplication.v2021_02_01_preview.models.ApplicationPackageContact + :ivar support_urls: The read-only support URLs property that is retrieved from the application + package. + :vartype support_urls: + ~azure.mgmt.managedapplication.v2021_02_01_preview.models.ApplicationPackageSupportUrls + :ivar artifacts: The collection of managed application artifacts. + :vartype artifacts: + list[~azure.mgmt.managedapplication.v2021_02_01_preview.models.ApplicationArtifact] + :ivar created_by: The client entity that created the JIT request. + :vartype created_by: + ~azure.mgmt.managedapplication.v2021_02_01_preview.models.ApplicationClientDetails + :ivar updated_by: The client entity that last updated the JIT request. + :vartype updated_by: + ~azure.mgmt.managedapplication.v2021_02_01_preview.models.ApplicationClientDetails + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'system_data': {'readonly': True}, + 'kind': {'pattern': r'^[-\w\._,\(\)]+$'}, + 'outputs': {'readonly': True}, + 'provisioning_state': {'readonly': True}, + 'billing_details': {'readonly': True}, + 'publisher_tenant_id': {'readonly': True}, + 'authorizations': {'readonly': True}, + 'management_mode': {'readonly': True}, + 'customer_support': {'readonly': True}, + 'support_urls': {'readonly': True}, + 'artifacts': {'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'}, + 'location': {'key': 'location', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + 'system_data': {'key': 'systemData', 'type': 'SystemData'}, + 'managed_by': {'key': 'managedBy', 'type': 'str'}, + 'sku': {'key': 'sku', 'type': 'Sku'}, + 'plan': {'key': 'plan', 'type': 'PlanPatchable'}, + 'kind': {'key': 'kind', 'type': 'str'}, + 'identity': {'key': 'identity', 'type': 'Identity'}, + 'managed_resource_group_id': {'key': 'properties.managedResourceGroupId', 'type': 'str'}, + 'application_definition_id': {'key': 'properties.applicationDefinitionId', 'type': 'str'}, + 'parameters': {'key': 'properties.parameters', 'type': 'object'}, + 'outputs': {'key': 'properties.outputs', 'type': 'object'}, + 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + 'billing_details': {'key': 'properties.billingDetails', 'type': 'ApplicationBillingDetailsDefinition'}, + 'jit_access_policy': {'key': 'properties.jitAccessPolicy', 'type': 'ApplicationJitAccessPolicy'}, + 'publisher_tenant_id': {'key': 'properties.publisherTenantId', 'type': 'str'}, + 'authorizations': {'key': 'properties.authorizations', 'type': '[ApplicationAuthorization]'}, + 'management_mode': {'key': 'properties.managementMode', 'type': 'str'}, + 'customer_support': {'key': 'properties.customerSupport', 'type': 'ApplicationPackageContact'}, + 'support_urls': {'key': 'properties.supportUrls', 'type': 'ApplicationPackageSupportUrls'}, + 'artifacts': {'key': 'properties.artifacts', 'type': '[ApplicationArtifact]'}, + 'created_by': {'key': 'properties.createdBy', 'type': 'ApplicationClientDetails'}, + 'updated_by': {'key': 'properties.updatedBy', 'type': 'ApplicationClientDetails'}, + } + + def __init__( + self, + *, + location: Optional[str] = None, + tags: Optional[Dict[str, str]] = None, + managed_by: Optional[str] = None, + sku: Optional["_models.Sku"] = None, + plan: Optional["_models.PlanPatchable"] = None, + kind: Optional[str] = None, + identity: Optional["_models.Identity"] = None, + managed_resource_group_id: Optional[str] = None, + application_definition_id: Optional[str] = None, + parameters: Optional[Any] = None, + jit_access_policy: Optional["_models.ApplicationJitAccessPolicy"] = None, + **kwargs + ): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword managed_by: ID of the resource that manages this resource. + :paramtype managed_by: str + :keyword sku: The SKU of the resource. + :paramtype sku: ~azure.mgmt.managedapplication.v2021_02_01_preview.models.Sku + :keyword plan: The plan information. + :paramtype plan: ~azure.mgmt.managedapplication.v2021_02_01_preview.models.PlanPatchable + :keyword kind: The kind of the managed application. Allowed values are MarketPlace and + ServiceCatalog. + :paramtype kind: str + :keyword identity: The identity of the resource. + :paramtype identity: ~azure.mgmt.managedapplication.v2021_02_01_preview.models.Identity + :keyword managed_resource_group_id: The managed resource group Id. + :paramtype managed_resource_group_id: str + :keyword application_definition_id: The fully qualified path of managed application definition + Id. + :paramtype application_definition_id: str + :keyword parameters: Name and value pairs that define the managed application parameters. It + can be a JObject or a well formed JSON string. + :paramtype parameters: any + :keyword jit_access_policy: The managed application Jit access policy. + :paramtype jit_access_policy: + ~azure.mgmt.managedapplication.v2021_02_01_preview.models.ApplicationJitAccessPolicy + """ + super(ApplicationPatchable, self).__init__(location=location, tags=tags, managed_by=managed_by, sku=sku, **kwargs) + self.plan = plan + self.kind = kind + self.identity = identity + self.managed_resource_group_id = managed_resource_group_id + self.application_definition_id = application_definition_id + self.parameters = parameters + self.outputs = None + self.provisioning_state = None + self.billing_details = None + self.jit_access_policy = jit_access_policy + self.publisher_tenant_id = None + self.authorizations = None + self.management_mode = None + self.customer_support = None + self.support_urls = None + self.artifacts = None + self.created_by = None + self.updated_by = None + + +class ApplicationPolicy(msrest.serialization.Model): + """Managed application policy. + + :ivar name: The policy name. + :vartype name: str + :ivar policy_definition_id: The policy definition Id. + :vartype policy_definition_id: str + :ivar parameters: The policy parameters. + :vartype parameters: str + """ + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'policy_definition_id': {'key': 'policyDefinitionId', 'type': 'str'}, + 'parameters': {'key': 'parameters', 'type': 'str'}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + policy_definition_id: Optional[str] = None, + parameters: Optional[str] = None, + **kwargs + ): + """ + :keyword name: The policy name. + :paramtype name: str + :keyword policy_definition_id: The policy definition Id. + :paramtype policy_definition_id: str + :keyword parameters: The policy parameters. + :paramtype parameters: str + """ + super(ApplicationPolicy, self).__init__(**kwargs) + self.name = name + self.policy_definition_id = policy_definition_id + self.parameters = parameters + + +class ApplicationPropertiesPatchable(msrest.serialization.Model): + """The managed application properties. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar managed_resource_group_id: The managed resource group Id. + :vartype managed_resource_group_id: str + :ivar application_definition_id: The fully qualified path of managed application definition Id. + :vartype application_definition_id: str + :ivar parameters: Name and value pairs that define the managed application parameters. It can + be a JObject or a well formed JSON string. + :vartype parameters: any + :ivar outputs: Name and value pairs that define the managed application outputs. + :vartype outputs: any + :ivar provisioning_state: The managed application provisioning state. Known values are: + "NotSpecified", "Accepted", "Running", "Ready", "Creating", "Created", "Deleting", "Deleted", + "Canceled", "Failed", "Succeeded", "Updating". + :vartype provisioning_state: str or + ~azure.mgmt.managedapplication.v2021_02_01_preview.models.ProvisioningState + """ + + _validation = { + 'outputs': {'readonly': True}, + 'provisioning_state': {'readonly': True}, + } + + _attribute_map = { + 'managed_resource_group_id': {'key': 'managedResourceGroupId', 'type': 'str'}, + 'application_definition_id': {'key': 'applicationDefinitionId', 'type': 'str'}, + 'parameters': {'key': 'parameters', 'type': 'object'}, + 'outputs': {'key': 'outputs', 'type': 'object'}, + 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, + } + + def __init__( + self, + *, + managed_resource_group_id: Optional[str] = None, + application_definition_id: Optional[str] = None, + parameters: Optional[Any] = None, + **kwargs + ): + """ + :keyword managed_resource_group_id: The managed resource group Id. + :paramtype managed_resource_group_id: str + :keyword application_definition_id: The fully qualified path of managed application definition + Id. + :paramtype application_definition_id: str + :keyword parameters: Name and value pairs that define the managed application parameters. It + can be a JObject or a well formed JSON string. + :paramtype parameters: any + """ + super(ApplicationPropertiesPatchable, self).__init__(**kwargs) + self.managed_resource_group_id = managed_resource_group_id + self.application_definition_id = application_definition_id + self.parameters = parameters + self.outputs = None + self.provisioning_state = None + + +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.managedapplication.v2021_02_01_preview.models.ErrorDetail] + :ivar additional_info: The error additional info. + :vartype additional_info: + list[~azure.mgmt.managedapplication.v2021_02_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.). + + :ivar error: The error object. + :vartype error: ~azure.mgmt.managedapplication.v2021_02_01_preview.models.ErrorDetail + """ + + _attribute_map = { + 'error': {'key': 'error', 'type': 'ErrorDetail'}, + } + + def __init__( + self, + *, + error: Optional["_models.ErrorDetail"] = None, + **kwargs + ): + """ + :keyword error: The error object. + :paramtype error: ~azure.mgmt.managedapplication.v2021_02_01_preview.models.ErrorDetail + """ + super(ErrorResponse, self).__init__(**kwargs) + self.error = error + + +class Identity(msrest.serialization.Model): + """Identity for the resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar principal_id: The principal ID of resource identity. + :vartype principal_id: str + :ivar tenant_id: The tenant ID of resource. + :vartype tenant_id: str + :ivar type: The identity type. Known values are: "SystemAssigned", "UserAssigned", + "SystemAssigned, UserAssigned", "None". + :vartype type: str or + ~azure.mgmt.managedapplication.v2021_02_01_preview.models.ResourceIdentityType + :ivar user_assigned_identities: The list of user identities associated with the resource. The + user identity dictionary key references will be resource ids in the form: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'. + :vartype user_assigned_identities: dict[str, + ~azure.mgmt.managedapplication.v2021_02_01_preview.models.UserAssignedResourceIdentity] + """ + + _validation = { + 'principal_id': {'readonly': True}, + 'tenant_id': {'readonly': True}, + } + + _attribute_map = { + 'principal_id': {'key': 'principalId', 'type': 'str'}, + 'tenant_id': {'key': 'tenantId', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'user_assigned_identities': {'key': 'userAssignedIdentities', 'type': '{UserAssignedResourceIdentity}'}, + } + + def __init__( + self, + *, + type: Optional[Union[str, "_models.ResourceIdentityType"]] = None, + user_assigned_identities: Optional[Dict[str, "_models.UserAssignedResourceIdentity"]] = None, + **kwargs + ): + """ + :keyword type: The identity type. Known values are: "SystemAssigned", "UserAssigned", + "SystemAssigned, UserAssigned", "None". + :paramtype type: str or + ~azure.mgmt.managedapplication.v2021_02_01_preview.models.ResourceIdentityType + :keyword user_assigned_identities: The list of user identities associated with the resource. + The user identity dictionary key references will be resource ids in the form: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'. + :paramtype user_assigned_identities: dict[str, + ~azure.mgmt.managedapplication.v2021_02_01_preview.models.UserAssignedResourceIdentity] + """ + super(Identity, self).__init__(**kwargs) + self.principal_id = None + self.tenant_id = None + self.type = type + self.user_assigned_identities = user_assigned_identities + + +class JitApproverDefinition(msrest.serialization.Model): + """JIT approver definition. + + All required parameters must be populated in order to send to Azure. + + :ivar id: Required. The approver service principal Id. + :vartype id: str + :ivar type: The approver type. Known values are: "user", "group". + :vartype type: str or ~azure.mgmt.managedapplication.v2021_02_01_preview.models.JitApproverType + :ivar display_name: The approver display name. + :vartype display_name: str + """ + + _validation = { + 'id': {'required': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'display_name': {'key': 'displayName', 'type': 'str'}, + } + + def __init__( + self, + *, + id: str, + type: Optional[Union[str, "_models.JitApproverType"]] = None, + display_name: Optional[str] = None, + **kwargs + ): + """ + :keyword id: Required. The approver service principal Id. + :paramtype id: str + :keyword type: The approver type. Known values are: "user", "group". + :paramtype type: str or + ~azure.mgmt.managedapplication.v2021_02_01_preview.models.JitApproverType + :keyword display_name: The approver display name. + :paramtype display_name: str + """ + super(JitApproverDefinition, self).__init__(**kwargs) + self.id = id + self.type = type + self.display_name = display_name + + +class JitAuthorizationPolicies(msrest.serialization.Model): + """The JIT authorization policies. + + All required parameters must be populated in order to send to Azure. + + :ivar principal_id: Required. The the principal id that will be granted JIT access. + :vartype principal_id: str + :ivar role_definition_id: Required. The role definition id that will be granted to the + Principal. + :vartype role_definition_id: str + """ + + _validation = { + 'principal_id': {'required': True}, + 'role_definition_id': {'required': True}, + } + + _attribute_map = { + 'principal_id': {'key': 'principalId', 'type': 'str'}, + 'role_definition_id': {'key': 'roleDefinitionId', 'type': 'str'}, + } + + def __init__( + self, + *, + principal_id: str, + role_definition_id: str, + **kwargs + ): + """ + :keyword principal_id: Required. The the principal id that will be granted JIT access. + :paramtype principal_id: str + :keyword role_definition_id: Required. The role definition id that will be granted to the + Principal. + :paramtype role_definition_id: str + """ + super(JitAuthorizationPolicies, self).__init__(**kwargs) + self.principal_id = principal_id + self.role_definition_id = role_definition_id + + +class JitRequestDefinition(Resource): + """Information about JIT request definition. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Resource ID. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar location: Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~azure.mgmt.managedapplication.v2021_02_01_preview.models.SystemData + :ivar application_resource_id: The parent application id. + :vartype application_resource_id: str + :ivar publisher_tenant_id: The publisher tenant id. + :vartype publisher_tenant_id: str + :ivar jit_authorization_policies: The JIT authorization policies. + :vartype jit_authorization_policies: + list[~azure.mgmt.managedapplication.v2021_02_01_preview.models.JitAuthorizationPolicies] + :ivar jit_scheduling_policy: The JIT request properties. + :vartype jit_scheduling_policy: + ~azure.mgmt.managedapplication.v2021_02_01_preview.models.JitSchedulingPolicy + :ivar provisioning_state: The JIT request provisioning state. Known values are: "NotSpecified", + "Accepted", "Running", "Ready", "Creating", "Created", "Deleting", "Deleted", "Canceled", + "Failed", "Succeeded", "Updating". + :vartype provisioning_state: str or + ~azure.mgmt.managedapplication.v2021_02_01_preview.models.ProvisioningState + :ivar jit_request_state: The JIT request state. Known values are: "NotSpecified", "Pending", + "Approved", "Denied", "Failed", "Canceled", "Expired", "Timeout". + :vartype jit_request_state: str or + ~azure.mgmt.managedapplication.v2021_02_01_preview.models.JitRequestState + :ivar created_by: The client entity that created the JIT request. + :vartype created_by: + ~azure.mgmt.managedapplication.v2021_02_01_preview.models.ApplicationClientDetails + :ivar updated_by: The client entity that last updated the JIT request. + :vartype updated_by: + ~azure.mgmt.managedapplication.v2021_02_01_preview.models.ApplicationClientDetails + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'system_data': {'readonly': True}, + 'publisher_tenant_id': {'readonly': True}, + 'provisioning_state': {'readonly': True}, + 'jit_request_state': {'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'}, + 'location': {'key': 'location', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + 'system_data': {'key': 'systemData', 'type': 'SystemData'}, + 'application_resource_id': {'key': 'properties.applicationResourceId', 'type': 'str'}, + 'publisher_tenant_id': {'key': 'properties.publisherTenantId', 'type': 'str'}, + 'jit_authorization_policies': {'key': 'properties.jitAuthorizationPolicies', 'type': '[JitAuthorizationPolicies]'}, + 'jit_scheduling_policy': {'key': 'properties.jitSchedulingPolicy', 'type': 'JitSchedulingPolicy'}, + 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + 'jit_request_state': {'key': 'properties.jitRequestState', 'type': 'str'}, + 'created_by': {'key': 'properties.createdBy', 'type': 'ApplicationClientDetails'}, + 'updated_by': {'key': 'properties.updatedBy', 'type': 'ApplicationClientDetails'}, + } + + def __init__( + self, + *, + location: Optional[str] = None, + tags: Optional[Dict[str, str]] = None, + application_resource_id: Optional[str] = None, + jit_authorization_policies: Optional[List["_models.JitAuthorizationPolicies"]] = None, + jit_scheduling_policy: Optional["_models.JitSchedulingPolicy"] = None, + **kwargs + ): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword application_resource_id: The parent application id. + :paramtype application_resource_id: str + :keyword jit_authorization_policies: The JIT authorization policies. + :paramtype jit_authorization_policies: + list[~azure.mgmt.managedapplication.v2021_02_01_preview.models.JitAuthorizationPolicies] + :keyword jit_scheduling_policy: The JIT request properties. + :paramtype jit_scheduling_policy: + ~azure.mgmt.managedapplication.v2021_02_01_preview.models.JitSchedulingPolicy + """ + super(JitRequestDefinition, self).__init__(location=location, tags=tags, **kwargs) + self.application_resource_id = application_resource_id + self.publisher_tenant_id = None + self.jit_authorization_policies = jit_authorization_policies + self.jit_scheduling_policy = jit_scheduling_policy + self.provisioning_state = None + self.jit_request_state = None + self.created_by = None + self.updated_by = None + + +class JitRequestDefinitionListResult(msrest.serialization.Model): + """List of JIT requests. + + :ivar value: The array of Jit request definition. + :vartype value: + list[~azure.mgmt.managedapplication.v2021_02_01_preview.models.JitRequestDefinition] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[JitRequestDefinition]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["_models.JitRequestDefinition"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + """ + :keyword value: The array of Jit request definition. + :paramtype value: + list[~azure.mgmt.managedapplication.v2021_02_01_preview.models.JitRequestDefinition] + :keyword next_link: The URL to use for getting the next set of results. + :paramtype next_link: str + """ + super(JitRequestDefinitionListResult, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class JitRequestMetadata(msrest.serialization.Model): + """The JIT request metadata. + + :ivar origin_request_id: The origin request id. + :vartype origin_request_id: str + :ivar requestor_id: The requestor id. + :vartype requestor_id: str + :ivar tenant_display_name: The publisher's tenant name. + :vartype tenant_display_name: str + :ivar subject_display_name: The subject display name. + :vartype subject_display_name: str + """ + + _attribute_map = { + 'origin_request_id': {'key': 'originRequestId', 'type': 'str'}, + 'requestor_id': {'key': 'requestorId', 'type': 'str'}, + 'tenant_display_name': {'key': 'tenantDisplayName', 'type': 'str'}, + 'subject_display_name': {'key': 'subjectDisplayName', 'type': 'str'}, + } + + def __init__( + self, + *, + origin_request_id: Optional[str] = None, + requestor_id: Optional[str] = None, + tenant_display_name: Optional[str] = None, + subject_display_name: Optional[str] = None, + **kwargs + ): + """ + :keyword origin_request_id: The origin request id. + :paramtype origin_request_id: str + :keyword requestor_id: The requestor id. + :paramtype requestor_id: str + :keyword tenant_display_name: The publisher's tenant name. + :paramtype tenant_display_name: str + :keyword subject_display_name: The subject display name. + :paramtype subject_display_name: str + """ + super(JitRequestMetadata, self).__init__(**kwargs) + self.origin_request_id = origin_request_id + self.requestor_id = requestor_id + self.tenant_display_name = tenant_display_name + self.subject_display_name = subject_display_name + + +class JitRequestPatchable(msrest.serialization.Model): + """Information about JIT request. + + :ivar tags: A set of tags. Jit request tags. + :vartype tags: dict[str, str] + """ + + _attribute_map = { + 'tags': {'key': 'tags', 'type': '{str}'}, + } + + def __init__( + self, + *, + tags: Optional[Dict[str, str]] = None, + **kwargs + ): + """ + :keyword tags: A set of tags. Jit request tags. + :paramtype tags: dict[str, str] + """ + super(JitRequestPatchable, self).__init__(**kwargs) + self.tags = tags + + +class JitSchedulingPolicy(msrest.serialization.Model): + """The JIT scheduling policies. + + All required parameters must be populated in order to send to Azure. + + :ivar type: Required. The type of JIT schedule. Known values are: "NotSpecified", "Once", + "Recurring". + :vartype type: str or + ~azure.mgmt.managedapplication.v2021_02_01_preview.models.JitSchedulingType + :ivar duration: Required. The required duration of the JIT request. + :vartype duration: ~datetime.timedelta + :ivar start_time: Required. The start time of the request. + :vartype start_time: ~datetime.datetime + """ + + _validation = { + 'type': {'required': True}, + 'duration': {'required': True}, + 'start_time': {'required': True}, + } + + _attribute_map = { + 'type': {'key': 'type', 'type': 'str'}, + 'duration': {'key': 'duration', 'type': 'duration'}, + 'start_time': {'key': 'startTime', 'type': 'iso-8601'}, + } + + def __init__( + self, + *, + type: Union[str, "_models.JitSchedulingType"], + duration: datetime.timedelta, + start_time: datetime.datetime, + **kwargs + ): + """ + :keyword type: Required. The type of JIT schedule. Known values are: "NotSpecified", "Once", + "Recurring". + :paramtype type: str or + ~azure.mgmt.managedapplication.v2021_02_01_preview.models.JitSchedulingType + :keyword duration: Required. The required duration of the JIT request. + :paramtype duration: ~datetime.timedelta + :keyword start_time: Required. The start time of the request. + :paramtype start_time: ~datetime.datetime + """ + super(JitSchedulingPolicy, self).__init__(**kwargs) + self.type = type + self.duration = duration + self.start_time = start_time + + +class ListTokenRequest(msrest.serialization.Model): + """List token request body. + + :ivar authorization_audience: The authorization audience. + :vartype authorization_audience: str + :ivar user_assigned_identities: The user assigned identities. + :vartype user_assigned_identities: list[str] + """ + + _attribute_map = { + 'authorization_audience': {'key': 'authorizationAudience', 'type': 'str'}, + 'user_assigned_identities': {'key': 'userAssignedIdentities', 'type': '[str]'}, + } + + def __init__( + self, + *, + authorization_audience: Optional[str] = None, + user_assigned_identities: Optional[List[str]] = None, + **kwargs + ): + """ + :keyword authorization_audience: The authorization audience. + :paramtype authorization_audience: str + :keyword user_assigned_identities: The user assigned identities. + :paramtype user_assigned_identities: list[str] + """ + super(ListTokenRequest, self).__init__(**kwargs) + self.authorization_audience = authorization_audience + self.user_assigned_identities = user_assigned_identities + + +class ManagedIdentityToken(msrest.serialization.Model): + """The managed identity token for the managed app resource. + + :ivar access_token: The requested access token. + :vartype access_token: str + :ivar expires_in: The number of seconds the access token will be valid. + :vartype expires_in: str + :ivar expires_on: The timespan when the access token expires. This is represented as the number + of seconds from epoch. + :vartype expires_on: str + :ivar not_before: The timespan when the access token takes effect. This is represented as the + number of seconds from epoch. + :vartype not_before: str + :ivar authorization_audience: The aud (audience) the access token was request for. This is the + same as what was provided in the listTokens request. + :vartype authorization_audience: str + :ivar resource_id: The Azure resource ID for the issued token. This is either the managed + application ID or the user-assigned identity ID. + :vartype resource_id: str + :ivar token_type: The type of the token. + :vartype token_type: str + """ + + _attribute_map = { + 'access_token': {'key': 'accessToken', 'type': 'str'}, + 'expires_in': {'key': 'expiresIn', 'type': 'str'}, + 'expires_on': {'key': 'expiresOn', 'type': 'str'}, + 'not_before': {'key': 'notBefore', 'type': 'str'}, + 'authorization_audience': {'key': 'authorizationAudience', 'type': 'str'}, + 'resource_id': {'key': 'resourceId', 'type': 'str'}, + 'token_type': {'key': 'tokenType', 'type': 'str'}, + } + + def __init__( + self, + *, + access_token: Optional[str] = None, + expires_in: Optional[str] = None, + expires_on: Optional[str] = None, + not_before: Optional[str] = None, + authorization_audience: Optional[str] = None, + resource_id: Optional[str] = None, + token_type: Optional[str] = None, + **kwargs + ): + """ + :keyword access_token: The requested access token. + :paramtype access_token: str + :keyword expires_in: The number of seconds the access token will be valid. + :paramtype expires_in: str + :keyword expires_on: The timespan when the access token expires. This is represented as the + number of seconds from epoch. + :paramtype expires_on: str + :keyword not_before: The timespan when the access token takes effect. This is represented as + the number of seconds from epoch. + :paramtype not_before: str + :keyword authorization_audience: The aud (audience) the access token was request for. This is + the same as what was provided in the listTokens request. + :paramtype authorization_audience: str + :keyword resource_id: The Azure resource ID for the issued token. This is either the managed + application ID or the user-assigned identity ID. + :paramtype resource_id: str + :keyword token_type: The type of the token. + :paramtype token_type: str + """ + super(ManagedIdentityToken, self).__init__(**kwargs) + self.access_token = access_token + self.expires_in = expires_in + self.expires_on = expires_on + self.not_before = not_before + self.authorization_audience = authorization_audience + self.resource_id = resource_id + self.token_type = token_type + + +class ManagedIdentityTokenResult(msrest.serialization.Model): + """The array of managed identity tokens. + + :ivar value: The array of managed identity tokens. + :vartype value: + list[~azure.mgmt.managedapplication.v2021_02_01_preview.models.ManagedIdentityToken] + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[ManagedIdentityToken]'}, + } + + def __init__( + self, + *, + value: Optional[List["_models.ManagedIdentityToken"]] = None, + **kwargs + ): + """ + :keyword value: The array of managed identity tokens. + :paramtype value: + list[~azure.mgmt.managedapplication.v2021_02_01_preview.models.ManagedIdentityToken] + """ + super(ManagedIdentityTokenResult, self).__init__(**kwargs) + self.value = value + + +class Operation(msrest.serialization.Model): + """Details of a REST API operation, returned from the Resource Provider Operations API. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name: The name of the operation, as per Resource-Based Access Control (RBAC). Examples: + "Microsoft.Compute/virtualMachines/write", "Microsoft.Compute/virtualMachines/capture/action". + :vartype name: str + :ivar is_data_action: Whether the operation applies to data-plane. This is "true" for + data-plane operations and "false" for ARM/control-plane operations. + :vartype is_data_action: bool + :ivar display: Localized display information for this particular operation. + :vartype display: ~azure.mgmt.managedapplication.v2021_02_01_preview.models.OperationDisplay + :ivar origin: The intended executor of the operation; as in Resource Based Access Control + (RBAC) and audit logs UX. Default value is "user,system". Known values are: "user", "system", + "user,system". + :vartype origin: str or ~azure.mgmt.managedapplication.v2021_02_01_preview.models.Origin + :ivar action_type: Enum. Indicates the action type. "Internal" refers to actions that are for + internal only APIs. Known values are: "Internal". + :vartype action_type: str or + ~azure.mgmt.managedapplication.v2021_02_01_preview.models.ActionType + """ + + _validation = { + 'name': {'readonly': True}, + 'is_data_action': {'readonly': True}, + 'origin': {'readonly': True}, + 'action_type': {'readonly': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'is_data_action': {'key': 'isDataAction', 'type': 'bool'}, + 'display': {'key': 'display', 'type': 'OperationDisplay'}, + 'origin': {'key': 'origin', 'type': 'str'}, + 'action_type': {'key': 'actionType', 'type': 'str'}, + } + + def __init__( + self, + *, + display: Optional["_models.OperationDisplay"] = None, + **kwargs + ): + """ + :keyword display: Localized display information for this particular operation. + :paramtype display: ~azure.mgmt.managedapplication.v2021_02_01_preview.models.OperationDisplay + """ + super(Operation, self).__init__(**kwargs) + self.name = None + self.is_data_action = None + self.display = display + self.origin = None + self.action_type = None + + +class OperationAutoGenerated(msrest.serialization.Model): + """Microsoft.Solutions operation. + + :ivar name: Operation name: {provider}/{resource}/{operation}. + :vartype name: str + :ivar is_data_action: Indicates whether the operation is a data action. + :vartype is_data_action: bool + :ivar display: The object that represents the operation. + :vartype display: + ~azure.mgmt.managedapplication.v2021_02_01_preview.models.OperationDisplayAutoGenerated + """ + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'is_data_action': {'key': 'isDataAction', 'type': 'bool'}, + 'display': {'key': 'display', 'type': 'OperationDisplayAutoGenerated'}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + is_data_action: Optional[bool] = None, + display: Optional["_models.OperationDisplayAutoGenerated"] = None, + **kwargs + ): + """ + :keyword name: Operation name: {provider}/{resource}/{operation}. + :paramtype name: str + :keyword is_data_action: Indicates whether the operation is a data action. + :paramtype is_data_action: bool + :keyword display: The object that represents the operation. + :paramtype display: + ~azure.mgmt.managedapplication.v2021_02_01_preview.models.OperationDisplayAutoGenerated + """ + super(OperationAutoGenerated, self).__init__(**kwargs) + self.name = name + self.is_data_action = is_data_action + self.display = display + + +class OperationDisplay(msrest.serialization.Model): + """Localized display information for this particular operation. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar provider: The localized friendly form of the resource provider name, e.g. "Microsoft + Monitoring Insights" or "Microsoft Compute". + :vartype provider: str + :ivar resource: The localized friendly name of the resource type related to this operation. + E.g. "Virtual Machines" or "Job Schedule Collections". + :vartype resource: str + :ivar operation: The concise, localized friendly name for the operation; suitable for + dropdowns. E.g. "Create or Update Virtual Machine", "Restart Virtual Machine". + :vartype operation: str + :ivar description: The short, localized friendly description of the operation; suitable for + tool tips and detailed views. + :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 OperationDisplayAutoGenerated(msrest.serialization.Model): + """The object that represents the operation. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar provider: Service provider: Microsoft.Solutions. + :vartype provider: str + :ivar resource: Resource on which the operation is performed: Application, JitRequest, etc. + :vartype resource: str + :ivar operation: Operation type: Read, write, delete, etc. + :vartype operation: str + :ivar description: Localized friendly description for the operation. + :vartype description: str + """ + + _validation = { + '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, + *, + provider: Optional[str] = None, + resource: Optional[str] = None, + operation: Optional[str] = None, + **kwargs + ): + """ + :keyword provider: Service provider: Microsoft.Solutions. + :paramtype provider: str + :keyword resource: Resource on which the operation is performed: Application, JitRequest, etc. + :paramtype resource: str + :keyword operation: Operation type: Read, write, delete, etc. + :paramtype operation: str + """ + super(OperationDisplayAutoGenerated, self).__init__(**kwargs) + self.provider = provider + self.resource = resource + self.operation = operation + self.description = None + + +class OperationListResult(msrest.serialization.Model): + """A list of REST API operations supported by an Azure Resource Provider. It contains an URL link to get the next set of results. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: List of operations supported by the resource provider. + :vartype value: list[~azure.mgmt.managedapplication.v2021_02_01_preview.models.Operation] + :ivar next_link: URL to get the next set of operation list results (if there are any). + :vartype next_link: str + """ + + _validation = { + 'value': {'readonly': True}, + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Operation]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(OperationListResult, self).__init__(**kwargs) + self.value = None + self.next_link = None + + +class OperationListResultAutoGenerated(msrest.serialization.Model): + """Result of the request to list Microsoft.Solutions operations. It contains a list of operations and a URL link to get the next set of results. + + :ivar value: List of Microsoft.Solutions operations. + :vartype value: + list[~azure.mgmt.managedapplication.v2021_02_01_preview.models.OperationAutoGenerated] + :ivar next_link: URL to get the next set of operation list results if there are any. + :vartype next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[OperationAutoGenerated]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["_models.OperationAutoGenerated"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + """ + :keyword value: List of Microsoft.Solutions operations. + :paramtype value: + list[~azure.mgmt.managedapplication.v2021_02_01_preview.models.OperationAutoGenerated] + :keyword next_link: URL to get the next set of operation list results if there are any. + :paramtype next_link: str + """ + super(OperationListResultAutoGenerated, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class Plan(msrest.serialization.Model): + """Plan for the managed application. + + All required parameters must be populated in order to send to Azure. + + :ivar name: Required. The plan name. + :vartype name: str + :ivar publisher: Required. The publisher ID. + :vartype publisher: str + :ivar product: Required. The product code. + :vartype product: str + :ivar promotion_code: The promotion code. + :vartype promotion_code: str + :ivar version: Required. The plan's version. + :vartype version: str + """ + + _validation = { + 'name': {'required': True}, + 'publisher': {'required': True}, + 'product': {'required': True}, + 'version': {'required': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'publisher': {'key': 'publisher', 'type': 'str'}, + 'product': {'key': 'product', 'type': 'str'}, + 'promotion_code': {'key': 'promotionCode', 'type': 'str'}, + 'version': {'key': 'version', 'type': 'str'}, + } + + def __init__( + self, + *, + name: str, + publisher: str, + product: str, + version: str, + promotion_code: Optional[str] = None, + **kwargs + ): + """ + :keyword name: Required. The plan name. + :paramtype name: str + :keyword publisher: Required. The publisher ID. + :paramtype publisher: str + :keyword product: Required. The product code. + :paramtype product: str + :keyword promotion_code: The promotion code. + :paramtype promotion_code: str + :keyword version: Required. The plan's version. + :paramtype version: str + """ + super(Plan, self).__init__(**kwargs) + self.name = name + self.publisher = publisher + self.product = product + self.promotion_code = promotion_code + self.version = version + + +class PlanPatchable(msrest.serialization.Model): + """Plan for the managed application. + + :ivar name: The plan name. + :vartype name: str + :ivar publisher: The publisher ID. + :vartype publisher: str + :ivar product: The product code. + :vartype product: str + :ivar promotion_code: The promotion code. + :vartype promotion_code: str + :ivar version: The plan's version. + :vartype version: str + """ + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'publisher': {'key': 'publisher', 'type': 'str'}, + 'product': {'key': 'product', 'type': 'str'}, + 'promotion_code': {'key': 'promotionCode', 'type': 'str'}, + 'version': {'key': 'version', 'type': 'str'}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + publisher: Optional[str] = None, + product: Optional[str] = None, + promotion_code: Optional[str] = None, + version: Optional[str] = None, + **kwargs + ): + """ + :keyword name: The plan name. + :paramtype name: str + :keyword publisher: The publisher ID. + :paramtype publisher: str + :keyword product: The product code. + :paramtype product: str + :keyword promotion_code: The promotion code. + :paramtype promotion_code: str + :keyword version: The plan's version. + :paramtype version: str + """ + super(PlanPatchable, self).__init__(**kwargs) + self.name = name + self.publisher = publisher + self.product = product + self.promotion_code = promotion_code + self.version = version + + +class Sku(msrest.serialization.Model): + """SKU for the resource. + + All required parameters must be populated in order to send to Azure. + + :ivar name: Required. The SKU name. + :vartype name: str + :ivar tier: The SKU tier. + :vartype tier: str + :ivar size: The SKU size. + :vartype size: str + :ivar family: The SKU family. + :vartype family: str + :ivar model: The SKU model. + :vartype model: str + :ivar capacity: The SKU capacity. + :vartype capacity: int + """ + + _validation = { + 'name': {'required': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'tier': {'key': 'tier', 'type': 'str'}, + 'size': {'key': 'size', 'type': 'str'}, + 'family': {'key': 'family', 'type': 'str'}, + 'model': {'key': 'model', 'type': 'str'}, + 'capacity': {'key': 'capacity', 'type': 'int'}, + } + + def __init__( + self, + *, + name: str, + tier: Optional[str] = None, + size: Optional[str] = None, + family: Optional[str] = None, + model: Optional[str] = None, + capacity: Optional[int] = None, + **kwargs + ): + """ + :keyword name: Required. The SKU name. + :paramtype name: str + :keyword tier: The SKU tier. + :paramtype tier: str + :keyword size: The SKU size. + :paramtype size: str + :keyword family: The SKU family. + :paramtype family: str + :keyword model: The SKU model. + :paramtype model: str + :keyword capacity: The SKU capacity. + :paramtype capacity: int + """ + super(Sku, self).__init__(**kwargs) + self.name = name + self.tier = tier + self.size = size + self.family = family + self.model = model + self.capacity = capacity + + +class SystemData(msrest.serialization.Model): + """Metadata pertaining to creation and last modification of the resource. + + :ivar created_by: The identity that created the resource. + :vartype created_by: str + :ivar created_by_type: The type of identity that created the resource. Known values are: + "User", "Application", "ManagedIdentity", "Key". + :vartype created_by_type: str or + ~azure.mgmt.managedapplication.v2021_02_01_preview.models.CreatedByType + :ivar created_at: The timestamp of resource creation (UTC). + :vartype created_at: ~datetime.datetime + :ivar last_modified_by: The identity that last modified the resource. + :vartype last_modified_by: str + :ivar last_modified_by_type: The type of identity that last modified the resource. Known values + are: "User", "Application", "ManagedIdentity", "Key". + :vartype last_modified_by_type: str or + ~azure.mgmt.managedapplication.v2021_02_01_preview.models.CreatedByType + :ivar last_modified_at: The timestamp of resource last modification (UTC). + :vartype last_modified_at: ~datetime.datetime + """ + + _attribute_map = { + 'created_by': {'key': 'createdBy', 'type': 'str'}, + 'created_by_type': {'key': 'createdByType', 'type': 'str'}, + 'created_at': {'key': 'createdAt', 'type': 'iso-8601'}, + 'last_modified_by': {'key': 'lastModifiedBy', 'type': 'str'}, + 'last_modified_by_type': {'key': 'lastModifiedByType', 'type': 'str'}, + 'last_modified_at': {'key': 'lastModifiedAt', 'type': 'iso-8601'}, + } + + def __init__( + self, + *, + created_by: Optional[str] = None, + created_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, + created_at: Optional[datetime.datetime] = None, + last_modified_by: Optional[str] = None, + last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, + last_modified_at: Optional[datetime.datetime] = None, + **kwargs + ): + """ + :keyword created_by: The identity that created the resource. + :paramtype created_by: str + :keyword created_by_type: The type of identity that created the resource. Known values are: + "User", "Application", "ManagedIdentity", "Key". + :paramtype created_by_type: str or + ~azure.mgmt.managedapplication.v2021_02_01_preview.models.CreatedByType + :keyword created_at: The timestamp of resource creation (UTC). + :paramtype created_at: ~datetime.datetime + :keyword last_modified_by: The identity that last modified the resource. + :paramtype last_modified_by: str + :keyword last_modified_by_type: The type of identity that last modified the resource. Known + values are: "User", "Application", "ManagedIdentity", "Key". + :paramtype last_modified_by_type: str or + ~azure.mgmt.managedapplication.v2021_02_01_preview.models.CreatedByType + :keyword last_modified_at: The timestamp of resource last modification (UTC). + :paramtype last_modified_at: ~datetime.datetime + """ + super(SystemData, self).__init__(**kwargs) + self.created_by = created_by + self.created_by_type = created_by_type + self.created_at = created_at + self.last_modified_by = last_modified_by + self.last_modified_by_type = last_modified_by_type + self.last_modified_at = last_modified_at + + +class UpdateAccessDefinition(msrest.serialization.Model): + """Update access request definition. + + All required parameters must be populated in order to send to Azure. + + :ivar approver: The approver name. + :vartype approver: str + :ivar metadata: Required. The JIT request metadata. + :vartype metadata: ~azure.mgmt.managedapplication.v2021_02_01_preview.models.JitRequestMetadata + :ivar status: Required. The JIT status. Known values are: "NotSpecified", "Elevate", "Remove". + :vartype status: str or ~azure.mgmt.managedapplication.v2021_02_01_preview.models.Status + :ivar sub_status: Required. The JIT status. Known values are: "NotSpecified", "Approved", + "Denied", "Failed", "Expired", "Timeout". + :vartype sub_status: str or ~azure.mgmt.managedapplication.v2021_02_01_preview.models.Substatus + """ + + _validation = { + 'metadata': {'required': True}, + 'status': {'required': True}, + 'sub_status': {'required': True}, + } + + _attribute_map = { + 'approver': {'key': 'approver', 'type': 'str'}, + 'metadata': {'key': 'metadata', 'type': 'JitRequestMetadata'}, + 'status': {'key': 'status', 'type': 'str'}, + 'sub_status': {'key': 'subStatus', 'type': 'str'}, + } + + def __init__( + self, + *, + metadata: "_models.JitRequestMetadata", + status: Union[str, "_models.Status"], + sub_status: Union[str, "_models.Substatus"], + approver: Optional[str] = None, + **kwargs + ): + """ + :keyword approver: The approver name. + :paramtype approver: str + :keyword metadata: Required. The JIT request metadata. + :paramtype metadata: + ~azure.mgmt.managedapplication.v2021_02_01_preview.models.JitRequestMetadata + :keyword status: Required. The JIT status. Known values are: "NotSpecified", "Elevate", + "Remove". + :paramtype status: str or ~azure.mgmt.managedapplication.v2021_02_01_preview.models.Status + :keyword sub_status: Required. The JIT status. Known values are: "NotSpecified", "Approved", + "Denied", "Failed", "Expired", "Timeout". + :paramtype sub_status: str or + ~azure.mgmt.managedapplication.v2021_02_01_preview.models.Substatus + """ + super(UpdateAccessDefinition, self).__init__(**kwargs) + self.approver = approver + self.metadata = metadata + self.status = status + self.sub_status = sub_status + + +class UserAssignedResourceIdentity(msrest.serialization.Model): + """Represents the user assigned identity that is contained within the UserAssignedIdentities dictionary on ResourceIdentity. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar principal_id: The principal id of user assigned identity. + :vartype principal_id: str + :ivar tenant_id: The tenant id of user assigned identity. + :vartype tenant_id: str + """ + + _validation = { + 'principal_id': {'readonly': True}, + 'tenant_id': {'readonly': True}, + } + + _attribute_map = { + 'principal_id': {'key': 'principalId', 'type': 'str'}, + 'tenant_id': {'key': 'tenantId', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(UserAssignedResourceIdentity, self).__init__(**kwargs) + self.principal_id = None + self.tenant_id = None diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_02_01_preview/models/_patch.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_02_01_preview/models/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_02_01_preview/models/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_02_01_preview/operations/__init__.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_02_01_preview/operations/__init__.py new file mode 100644 index 000000000000..b93ecbbe65e2 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_02_01_preview/operations/__init__.py @@ -0,0 +1,24 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._application_client_operations import ApplicationClientOperationsMixin +from ._applications_operations import ApplicationsOperations +from ._application_definitions_operations import ApplicationDefinitionsOperations +from ._jit_requests_operations import JitRequestsOperations + +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk +__all__ = [ + 'ApplicationClientOperationsMixin', + 'ApplicationsOperations', + 'ApplicationDefinitionsOperations', + 'JitRequestsOperations', +] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_02_01_preview/operations/_application_client_operations.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_02_01_preview/operations/_application_client_operations.py new file mode 100644 index 000000000000..5d1abf5996cc --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_02_01_preview/operations/_application_client_operations.py @@ -0,0 +1,134 @@ +# 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.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._vendor import MixinABC, _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_operations_request( + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.Solutions/operations") + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + +class ApplicationClientOperationsMixin(MixinABC): + + @distributed_trace + def list_operations( + self, + **kwargs: Any + ) -> Iterable[_models.OperationListResult]: + """Lists all of the available Microsoft.Solutions REST API operations. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either OperationListResult or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.managedapplication.v2021_02_01_preview.models.OperationListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-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', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_operations_request( + api_version=api_version, + template_url=self.list_operations.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_operations_request( + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list_operations.metadata = {'url': "/providers/Microsoft.Solutions/operations"} # type: ignore diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_02_01_preview/operations/_application_definitions_operations.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_02_01_preview/operations/_application_definitions_operations.py new file mode 100644 index 000000000000..54932e46b4d6 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_02_01_preview/operations/_application_definitions_operations.py @@ -0,0 +1,1160 @@ +# 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.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._vendor import MixinABC, _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_request( + subscription_id: str, + resource_group_name: str, + application_definition_name: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}") # 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), + "applicationDefinitionName": _SERIALIZER.url("application_definition_name", application_definition_name, 'str', max_length=64, min_length=3), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_delete_request( + subscription_id: str, + resource_group_name: str, + application_definition_name: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}") # 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), + "applicationDefinitionName": _SERIALIZER.url("application_definition_name", application_definition_name, 'str', max_length=64, min_length=3), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_create_or_update_request( + subscription_id: str, + resource_group_name: str, + application_definition_name: str, + *, + json: Optional[_models.ApplicationDefinition] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}") # 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), + "applicationDefinitionName": _SERIALIZER.url("application_definition_name", application_definition_name, 'str', max_length=64, min_length=3), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_update_request( + subscription_id: str, + resource_group_name: str, + application_definition_name: str, + *, + json: Optional[_models.ApplicationDefinitionPatchable] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}") # 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), + "applicationDefinitionName": _SERIALIZER.url("application_definition_name", application_definition_name, 'str', max_length=64, min_length=3), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_list_by_resource_group_request( + subscription_id: str, + resource_group_name: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions") # 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 + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_list_by_subscription_request( + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Solutions/applicationDefinitions") + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_get_by_id_request( + resource_group_name: str, + application_definition_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "applicationDefinitionName": _SERIALIZER.url("application_definition_name", application_definition_name, 'str', max_length=64, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_delete_by_id_request( + resource_group_name: str, + application_definition_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "applicationDefinitionName": _SERIALIZER.url("application_definition_name", application_definition_name, 'str', max_length=64, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_create_or_update_by_id_request( + resource_group_name: str, + application_definition_name: str, + subscription_id: str, + *, + json: Optional[_models.ApplicationDefinition] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "applicationDefinitionName": _SERIALIZER.url("application_definition_name", application_definition_name, 'str', max_length=64, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_update_by_id_request( + subscription_id: str, + resource_group_name: str, + application_definition_name: str, + *, + json: Optional[_models.ApplicationDefinitionPatchable] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}") # 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), + "applicationDefinitionName": _SERIALIZER.url("application_definition_name", application_definition_name, 'str', max_length=64, min_length=3), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + +class ApplicationDefinitionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.managedapplication.v2021_02_01_preview.ApplicationClient`'s + :attr:`application_definitions` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + + @distributed_trace + def get( + self, + resource_group_name: str, + application_definition_name: str, + **kwargs: Any + ) -> Optional[_models.ApplicationDefinition]: + """Gets the managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. + :type application_definition_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ApplicationDefinition, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2021_02_01_preview.models.ApplicationDefinition or None + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.ApplicationDefinition]] + + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('ApplicationDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore + + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + application_definition_name: str, + **kwargs: Any + ) -> None: + """Deletes the managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. + :type application_definition_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + api_version=api_version, + template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore + + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + application_definition_name: str, + parameters: _models.ApplicationDefinition, + **kwargs: Any + ) -> _models.ApplicationDefinition: + """Creates or updates a managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. + :type application_definition_name: str + :param parameters: Parameters supplied to the create or update an managed application + definition. + :type parameters: + ~azure.mgmt.managedapplication.v2021_02_01_preview.models.ApplicationDefinition + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ApplicationDefinition, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2021_02_01_preview.models.ApplicationDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationDefinition] + + _json = self._serialize.body(parameters, 'ApplicationDefinition') + + request = build_create_or_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # 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, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('ApplicationDefinition', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('ApplicationDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore + + + @distributed_trace + def update( + self, + resource_group_name: str, + application_definition_name: str, + parameters: _models.ApplicationDefinitionPatchable, + **kwargs: Any + ) -> _models.ApplicationDefinition: + """Updates the managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. + :type application_definition_name: str + :param parameters: Parameters supplied to the update a managed application definition. + :type parameters: + ~azure.mgmt.managedapplication.v2021_02_01_preview.models.ApplicationDefinitionPatchable + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ApplicationDefinition, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2021_02_01_preview.models.ApplicationDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationDefinition] + + _json = self._serialize.body(parameters, 'ApplicationDefinitionPatchable') + + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ApplicationDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore + + + @distributed_trace + def list_by_resource_group( + self, + resource_group_name: str, + **kwargs: Any + ) -> Iterable[_models.ApplicationDefinitionListResult]: + """Lists the managed application definitions in a resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ApplicationDefinitionListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.managedapplication.v2021_02_01_preview.models.ApplicationDefinitionListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationDefinitionListResult] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + api_version=api_version, + template_url=self.list_by_resource_group.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ApplicationDefinitionListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions"} # type: ignore + + @distributed_trace + def list_by_subscription( + self, + **kwargs: Any + ) -> Iterable[_models.ApplicationDefinitionListResult]: + """Gets all the application definitions within a subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ApplicationDefinitionListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.managedapplication.v2021_02_01_preview.models.ApplicationDefinitionListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationDefinitionListResult] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ApplicationDefinitionListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Solutions/applicationDefinitions"} # type: ignore + + @distributed_trace + def get_by_id( + self, + resource_group_name: str, + application_definition_name: str, + **kwargs: Any + ) -> Optional[_models.ApplicationDefinition]: + """Gets the managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. + :type application_definition_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ApplicationDefinition, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2021_02_01_preview.models.ApplicationDefinition or None + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.ApplicationDefinition]] + + + request = build_get_by_id_request( + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_by_id.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('ApplicationDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_by_id.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore + + + @distributed_trace + def delete_by_id( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + application_definition_name: str, + **kwargs: Any + ) -> None: + """Deletes the managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. + :type application_definition_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_by_id_request( + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete_by_id.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete_by_id.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore + + + @distributed_trace + def create_or_update_by_id( + self, + resource_group_name: str, + application_definition_name: str, + parameters: _models.ApplicationDefinition, + **kwargs: Any + ) -> _models.ApplicationDefinition: + """Creates or updates managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. + :type application_definition_name: str + :param parameters: Parameters supplied to the create or update a managed application + definition. + :type parameters: + ~azure.mgmt.managedapplication.v2021_02_01_preview.models.ApplicationDefinition + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ApplicationDefinition, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2021_02_01_preview.models.ApplicationDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationDefinition] + + _json = self._serialize.body(parameters, 'ApplicationDefinition') + + request = build_create_or_update_by_id_request( + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + 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'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # 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, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('ApplicationDefinition', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('ApplicationDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_or_update_by_id.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore + + + @distributed_trace + def update_by_id( + self, + resource_group_name: str, + application_definition_name: str, + parameters: _models.ApplicationDefinitionPatchable, + **kwargs: Any + ) -> _models.ApplicationDefinition: + """Updates the managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. + :type application_definition_name: str + :param parameters: Parameters supplied to the update a managed application definition. + :type parameters: + ~azure.mgmt.managedapplication.v2021_02_01_preview.models.ApplicationDefinitionPatchable + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ApplicationDefinition, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2021_02_01_preview.models.ApplicationDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationDefinition] + + _json = self._serialize.body(parameters, 'ApplicationDefinitionPatchable') + + request = build_update_by_id_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.update_by_id.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ApplicationDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + update_by_id.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore + diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_02_01_preview/operations/_applications_operations.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_02_01_preview/operations/_applications_operations.py new file mode 100644 index 000000000000..4367338eb274 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_02_01_preview/operations/_applications_operations.py @@ -0,0 +1,2093 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast + +from msrest import Serializer + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from .._vendor import MixinABC, _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_request( + subscription_id: str, + resource_group_name: str, + application_name: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}") # 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), + "applicationName": _SERIALIZER.url("application_name", application_name, 'str', max_length=64, min_length=3), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_delete_request_initial( + subscription_id: str, + resource_group_name: str, + application_name: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}") # 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), + "applicationName": _SERIALIZER.url("application_name", application_name, 'str', max_length=64, min_length=3), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_create_or_update_request_initial( + subscription_id: str, + resource_group_name: str, + application_name: str, + *, + json: Optional[_models.Application] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}") # 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), + "applicationName": _SERIALIZER.url("application_name", application_name, 'str', max_length=64, min_length=3), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_update_request_initial( + subscription_id: str, + resource_group_name: str, + application_name: str, + *, + json: Optional[_models.ApplicationPatchable] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}") # 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), + "applicationName": _SERIALIZER.url("application_name", application_name, 'str', max_length=64, min_length=3), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_list_by_resource_group_request( + subscription_id: str, + resource_group_name: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications") # 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 + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_list_by_subscription_request( + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Solutions/applications") + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_get_by_id_request( + application_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/{applicationId}") + path_format_arguments = { + "applicationId": _SERIALIZER.url("application_id", application_id, 'str', skip_quote=True), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_delete_by_id_request_initial( + application_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/{applicationId}") + path_format_arguments = { + "applicationId": _SERIALIZER.url("application_id", application_id, 'str', skip_quote=True), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_create_or_update_by_id_request_initial( + application_id: str, + *, + json: Optional[_models.Application] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/{applicationId}") + path_format_arguments = { + "applicationId": _SERIALIZER.url("application_id", application_id, 'str', skip_quote=True), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_update_by_id_request_initial( + application_id: str, + *, + json: Optional[_models.ApplicationPatchable] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/{applicationId}") + path_format_arguments = { + "applicationId": _SERIALIZER.url("application_id", application_id, 'str', skip_quote=True), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_refresh_permissions_request_initial( + subscription_id: str, + resource_group_name: str, + application_name: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}/refreshPermissions") # 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), + "applicationName": _SERIALIZER.url("application_name", application_name, 'str', max_length=64, min_length=3), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_list_allowed_upgrade_plans_request( + subscription_id: str, + resource_group_name: str, + application_name: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}/listAllowedUpgradePlans") # 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), + "applicationName": _SERIALIZER.url("application_name", application_name, 'str', max_length=64, min_length=3), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_update_access_request_initial( + subscription_id: str, + resource_group_name: str, + application_name: str, + *, + json: Optional[_models.UpdateAccessDefinition] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}/updateAccess") # 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), + "applicationName": _SERIALIZER.url("application_name", application_name, 'str', max_length=64, min_length=3), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_list_tokens_request( + subscription_id: str, + resource_group_name: str, + application_name: str, + *, + json: Optional[_models.ListTokenRequest] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}/listTokens") # 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), + "applicationName": _SERIALIZER.url("application_name", application_name, 'str', max_length=64, min_length=3), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + +class ApplicationsOperations: # pylint: disable=too-many-public-methods + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.managedapplication.v2021_02_01_preview.ApplicationClient`'s + :attr:`applications` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + + @distributed_trace + def get( + self, + resource_group_name: str, + application_name: str, + **kwargs: Any + ) -> Optional[_models.Application]: + """Gets the managed application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_name: The name of the managed application. + :type application_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Application, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2021_02_01_preview.models.Application or None + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.Application]] + + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + application_name=application_name, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('Application', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}"} # type: ignore + + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + application_name: str, + **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + application_name=application_name, + api_version=api_version, + template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}"} # type: ignore + + + @distributed_trace + def begin_delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + application_name: str, + **kwargs: Any + ) -> LROPoller[None]: + """Deletes the managed application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_name: The name of the managed application. + :type application_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._delete_initial( # type: ignore + resource_group_name=resource_group_name, + application_name=application_name, + api_version=api_version, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}"} # type: ignore + + def _create_or_update_initial( + self, + resource_group_name: str, + application_name: str, + parameters: _models.Application, + **kwargs: Any + ) -> _models.Application: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Application] + + _json = self._serialize.body(parameters, 'Application') + + request = build_create_or_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + application_name=application_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('Application', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('Application', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}"} # type: ignore + + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + application_name: str, + parameters: _models.Application, + **kwargs: Any + ) -> LROPoller[_models.Application]: + """Creates or update managed application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_name: The name of the managed application. + :type application_name: str + :param parameters: Parameters supplied to the create or update a managed application. + :type parameters: ~azure.mgmt.managedapplication.v2021_02_01_preview.models.Application + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Application or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.managedapplication.v2021_02_01_preview.models.Application] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Application] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._create_or_update_initial( # type: ignore + resource_group_name=resource_group_name, + application_name=application_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('Application', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}"} # type: ignore + + def _update_initial( + self, + resource_group_name: str, + application_name: str, + parameters: Optional[_models.ApplicationPatchable] = None, + **kwargs: Any + ) -> _models.ApplicationPatchable: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationPatchable] + + if parameters is not None: + _json = self._serialize.body(parameters, 'ApplicationPatchable') + else: + _json = None + + request = build_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + application_name=application_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('ApplicationPatchable', pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize('ApplicationPatchable', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}"} # type: ignore + + + @distributed_trace + def begin_update( + self, + resource_group_name: str, + application_name: str, + parameters: Optional[_models.ApplicationPatchable] = None, + **kwargs: Any + ) -> LROPoller[_models.ApplicationPatchable]: + """Updates an existing managed application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_name: The name of the managed application. + :type application_name: str + :param parameters: Parameters supplied to update an existing managed application. Default value + is None. + :type parameters: + ~azure.mgmt.managedapplication.v2021_02_01_preview.models.ApplicationPatchable + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ApplicationPatchable or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.managedapplication.v2021_02_01_preview.models.ApplicationPatchable] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationPatchable] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._update_initial( # type: ignore + resource_group_name=resource_group_name, + application_name=application_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('ApplicationPatchable', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}"} # type: ignore + + @distributed_trace + def list_by_resource_group( + self, + resource_group_name: str, + **kwargs: Any + ) -> Iterable[_models.ApplicationListResult]: + """Gets all the applications within a resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ApplicationListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.managedapplication.v2021_02_01_preview.models.ApplicationListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationListResult] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + api_version=api_version, + template_url=self.list_by_resource_group.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ApplicationListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications"} # type: ignore + + @distributed_trace + def list_by_subscription( + self, + **kwargs: Any + ) -> Iterable[_models.ApplicationListResult]: + """Gets all the applications within a subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ApplicationListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.managedapplication.v2021_02_01_preview.models.ApplicationListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationListResult] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ApplicationListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Solutions/applications"} # type: ignore + + @distributed_trace + def get_by_id( + self, + application_id: str, + **kwargs: Any + ) -> Optional[_models.Application]: + """Gets the managed application. + + :param application_id: The fully qualified ID of the managed application, including the managed + application name and the managed application resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/Microsoft.Solutions/applications/{application-name}. + :type application_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Application, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2021_02_01_preview.models.Application or None + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.Application]] + + + request = build_get_by_id_request( + application_id=application_id, + api_version=api_version, + template_url=self.get_by_id.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('Application', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_by_id.metadata = {'url': "/{applicationId}"} # type: ignore + + + def _delete_by_id_initial( # pylint: disable=inconsistent-return-statements + self, + application_id: str, + **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_by_id_request_initial( + application_id=application_id, + api_version=api_version, + template_url=self._delete_by_id_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_by_id_initial.metadata = {'url': "/{applicationId}"} # type: ignore + + + @distributed_trace + def begin_delete_by_id( # pylint: disable=inconsistent-return-statements + self, + application_id: str, + **kwargs: Any + ) -> LROPoller[None]: + """Deletes the managed application. + + :param application_id: The fully qualified ID of the managed application, including the managed + application name and the managed application resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/Microsoft.Solutions/applications/{application-name}. + :type application_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._delete_by_id_initial( # type: ignore + application_id=application_id, + api_version=api_version, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete_by_id.metadata = {'url': "/{applicationId}"} # type: ignore + + def _create_or_update_by_id_initial( + self, + application_id: str, + parameters: _models.Application, + **kwargs: Any + ) -> _models.Application: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Application] + + _json = self._serialize.body(parameters, 'Application') + + request = build_create_or_update_by_id_request_initial( + application_id=application_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._create_or_update_by_id_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('Application', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('Application', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_by_id_initial.metadata = {'url': "/{applicationId}"} # type: ignore + + + @distributed_trace + def begin_create_or_update_by_id( + self, + application_id: str, + parameters: _models.Application, + **kwargs: Any + ) -> LROPoller[_models.Application]: + """Creates or updates a managed application. + + :param application_id: The fully qualified ID of the managed application, including the managed + application name and the managed application resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/Microsoft.Solutions/applications/{application-name}. + :type application_id: str + :param parameters: Parameters supplied to the create or update a managed application. + :type parameters: ~azure.mgmt.managedapplication.v2021_02_01_preview.models.Application + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Application or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.managedapplication.v2021_02_01_preview.models.Application] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Application] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._create_or_update_by_id_initial( # type: ignore + application_id=application_id, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('Application', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update_by_id.metadata = {'url': "/{applicationId}"} # type: ignore + + def _update_by_id_initial( + self, + application_id: str, + parameters: Optional[_models.ApplicationPatchable] = None, + **kwargs: Any + ) -> _models.ApplicationPatchable: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationPatchable] + + if parameters is not None: + _json = self._serialize.body(parameters, 'ApplicationPatchable') + else: + _json = None + + request = build_update_by_id_request_initial( + application_id=application_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._update_by_id_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('ApplicationPatchable', pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize('ApplicationPatchable', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _update_by_id_initial.metadata = {'url': "/{applicationId}"} # type: ignore + + + @distributed_trace + def begin_update_by_id( + self, + application_id: str, + parameters: Optional[_models.ApplicationPatchable] = None, + **kwargs: Any + ) -> LROPoller[_models.ApplicationPatchable]: + """Updates an existing managed application. + + :param application_id: The fully qualified ID of the managed application, including the managed + application name and the managed application resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/Microsoft.Solutions/applications/{application-name}. + :type application_id: str + :param parameters: Parameters supplied to update an existing managed application. Default value + is None. + :type parameters: + ~azure.mgmt.managedapplication.v2021_02_01_preview.models.ApplicationPatchable + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ApplicationPatchable or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.managedapplication.v2021_02_01_preview.models.ApplicationPatchable] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationPatchable] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._update_by_id_initial( # type: ignore + application_id=application_id, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('ApplicationPatchable', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_update_by_id.metadata = {'url': "/{applicationId}"} # type: ignore + + def _refresh_permissions_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + application_name: str, + **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_refresh_permissions_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + application_name=application_name, + api_version=api_version, + template_url=self._refresh_permissions_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _refresh_permissions_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}/refreshPermissions"} # type: ignore + + + @distributed_trace + def begin_refresh_permissions( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + application_name: str, + **kwargs: Any + ) -> LROPoller[None]: + """Refresh Permissions for application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_name: The name of the managed application. + :type application_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._refresh_permissions_initial( # type: ignore + resource_group_name=resource_group_name, + application_name=application_name, + api_version=api_version, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'location'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_refresh_permissions.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}/refreshPermissions"} # type: ignore + + @distributed_trace + def list_allowed_upgrade_plans( + self, + resource_group_name: str, + application_name: str, + **kwargs: Any + ) -> _models.AllowedUpgradePlansResult: + """List allowed upgrade plans for application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_name: The name of the managed application. + :type application_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AllowedUpgradePlansResult, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2021_02_01_preview.models.AllowedUpgradePlansResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AllowedUpgradePlansResult] + + + request = build_list_allowed_upgrade_plans_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + application_name=application_name, + api_version=api_version, + template_url=self.list_allowed_upgrade_plans.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('AllowedUpgradePlansResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_allowed_upgrade_plans.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}/listAllowedUpgradePlans"} # type: ignore + + + def _update_access_initial( + self, + resource_group_name: str, + application_name: str, + parameters: _models.UpdateAccessDefinition, + **kwargs: Any + ) -> Optional[_models.UpdateAccessDefinition]: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.UpdateAccessDefinition]] + + _json = self._serialize.body(parameters, 'UpdateAccessDefinition') + + request = build_update_access_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + application_name=application_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._update_access_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 202: + deserialized = self._deserialize('UpdateAccessDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _update_access_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}/updateAccess"} # type: ignore + + + @distributed_trace + def begin_update_access( + self, + resource_group_name: str, + application_name: str, + parameters: _models.UpdateAccessDefinition, + **kwargs: Any + ) -> LROPoller[_models.UpdateAccessDefinition]: + """Update access for application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_name: The name of the managed application. + :type application_name: str + :param parameters: Request body parameters to update access. + :type parameters: + ~azure.mgmt.managedapplication.v2021_02_01_preview.models.UpdateAccessDefinition + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either UpdateAccessDefinition or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.managedapplication.v2021_02_01_preview.models.UpdateAccessDefinition] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.UpdateAccessDefinition] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._update_access_initial( # type: ignore + resource_group_name=resource_group_name, + application_name=application_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('UpdateAccessDefinition', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'location'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_update_access.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}/updateAccess"} # type: ignore + + @distributed_trace + def list_tokens( + self, + resource_group_name: str, + application_name: str, + parameters: _models.ListTokenRequest, + **kwargs: Any + ) -> _models.ManagedIdentityTokenResult: + """List tokens for application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_name: The name of the managed application. + :type application_name: str + :param parameters: Request body parameters to list tokens. + :type parameters: ~azure.mgmt.managedapplication.v2021_02_01_preview.models.ListTokenRequest + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ManagedIdentityTokenResult, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2021_02_01_preview.models.ManagedIdentityTokenResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ManagedIdentityTokenResult] + + _json = self._serialize.body(parameters, 'ListTokenRequest') + + request = build_list_tokens_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + application_name=application_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.list_tokens.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ManagedIdentityTokenResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_tokens.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}/listTokens"} # type: ignore + diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_02_01_preview/operations/_jit_requests_operations.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_02_01_preview/operations/_jit_requests_operations.py new file mode 100644 index 000000000000..d7390a6620d2 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_02_01_preview/operations/_jit_requests_operations.py @@ -0,0 +1,739 @@ +# 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, Union, cast + +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.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from .._vendor import MixinABC, _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_request( + subscription_id: str, + resource_group_name: str, + jit_request_name: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/jitRequests/{jitRequestName}") # 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), + "jitRequestName": _SERIALIZER.url("jit_request_name", jit_request_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_create_or_update_request_initial( + subscription_id: str, + resource_group_name: str, + jit_request_name: str, + *, + json: Optional[_models.JitRequestDefinition] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/jitRequests/{jitRequestName}") # 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), + "jitRequestName": _SERIALIZER.url("jit_request_name", jit_request_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_update_request( + subscription_id: str, + resource_group_name: str, + jit_request_name: str, + *, + json: Optional[_models.JitRequestPatchable] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/jitRequests/{jitRequestName}") # 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), + "jitRequestName": _SERIALIZER.url("jit_request_name", jit_request_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request( + subscription_id: str, + resource_group_name: str, + jit_request_name: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/jitRequests/{jitRequestName}") # 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), + "jitRequestName": _SERIALIZER.url("jit_request_name", jit_request_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_list_by_subscription_request( + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Solutions/jitRequests") + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_list_by_resource_group_request( + subscription_id: str, + resource_group_name: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/jitRequests") # 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 + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + +class JitRequestsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.managedapplication.v2021_02_01_preview.ApplicationClient`'s + :attr:`jit_requests` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + + @distributed_trace + def get( + self, + resource_group_name: str, + jit_request_name: str, + **kwargs: Any + ) -> Optional[_models.JitRequestDefinition]: + """Gets the JIT request. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param jit_request_name: The name of the JIT request. + :type jit_request_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JitRequestDefinition, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2021_02_01_preview.models.JitRequestDefinition or None + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.JitRequestDefinition]] + + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + jit_request_name=jit_request_name, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('JitRequestDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/jitRequests/{jitRequestName}"} # type: ignore + + + def _create_or_update_initial( + self, + resource_group_name: str, + jit_request_name: str, + parameters: _models.JitRequestDefinition, + **kwargs: Any + ) -> _models.JitRequestDefinition: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.JitRequestDefinition] + + _json = self._serialize.body(parameters, 'JitRequestDefinition') + + request = build_create_or_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + jit_request_name=jit_request_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('JitRequestDefinition', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('JitRequestDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/jitRequests/{jitRequestName}"} # type: ignore + + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + jit_request_name: str, + parameters: _models.JitRequestDefinition, + **kwargs: Any + ) -> LROPoller[_models.JitRequestDefinition]: + """Creates or updates the JIT request. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param jit_request_name: The name of the JIT request. + :type jit_request_name: str + :param parameters: Parameters supplied to the update JIT request. + :type parameters: + ~azure.mgmt.managedapplication.v2021_02_01_preview.models.JitRequestDefinition + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either JitRequestDefinition or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.managedapplication.v2021_02_01_preview.models.JitRequestDefinition] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.JitRequestDefinition] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._create_or_update_initial( # type: ignore + resource_group_name=resource_group_name, + jit_request_name=jit_request_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('JitRequestDefinition', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/jitRequests/{jitRequestName}"} # type: ignore + + @distributed_trace + def update( + self, + resource_group_name: str, + jit_request_name: str, + parameters: _models.JitRequestPatchable, + **kwargs: Any + ) -> _models.JitRequestDefinition: + """Updates the JIT request. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param jit_request_name: The name of the JIT request. + :type jit_request_name: str + :param parameters: Parameters supplied to the update JIT request. + :type parameters: ~azure.mgmt.managedapplication.v2021_02_01_preview.models.JitRequestPatchable + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JitRequestDefinition, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2021_02_01_preview.models.JitRequestDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.JitRequestDefinition] + + _json = self._serialize.body(parameters, 'JitRequestPatchable') + + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + jit_request_name=jit_request_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('JitRequestDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/jitRequests/{jitRequestName}"} # type: ignore + + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + jit_request_name: str, + **kwargs: Any + ) -> None: + """Deletes the JIT request. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param jit_request_name: The name of the JIT request. + :type jit_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 + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + jit_request_name=jit_request_name, + api_version=api_version, + template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/jitRequests/{jitRequestName}"} # type: ignore + + + @distributed_trace + def list_by_subscription( + self, + **kwargs: Any + ) -> _models.JitRequestDefinitionListResult: + """Lists all JIT requests within the subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JitRequestDefinitionListResult, or the result of cls(response) + :rtype: + ~azure.mgmt.managedapplication.v2021_02_01_preview.models.JitRequestDefinitionListResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.JitRequestDefinitionListResult] + + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('JitRequestDefinitionListResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Solutions/jitRequests"} # type: ignore + + + @distributed_trace + def list_by_resource_group( + self, + resource_group_name: str, + **kwargs: Any + ) -> _models.JitRequestDefinitionListResult: + """Lists all JIT requests within the 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: JitRequestDefinitionListResult, or the result of cls(response) + :rtype: + ~azure.mgmt.managedapplication.v2021_02_01_preview.models.JitRequestDefinitionListResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.JitRequestDefinitionListResult] + + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + api_version=api_version, + template_url=self.list_by_resource_group.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('JitRequestDefinitionListResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/jitRequests"} # type: ignore + diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_02_01_preview/operations/_patch.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_02_01_preview/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_02_01_preview/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_02_01_preview/py.typed b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_02_01_preview/py.typed new file mode 100644 index 000000000000..e5aff4f83af8 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_02_01_preview/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_07_01/__init__.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_07_01/__init__.py new file mode 100644 index 000000000000..2e61ca12e56a --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_07_01/__init__.py @@ -0,0 +1,23 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._application_client import ApplicationClient +from ._version import VERSION + +__version__ = VERSION + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk +__all__ = ['ApplicationClient'] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_07_01/_application_client.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_07_01/_application_client.py new file mode 100644 index 000000000000..8976c26cd494 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_07_01/_application_client.py @@ -0,0 +1,112 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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 ApplicationClientConfiguration +from .operations import ApplicationClientOperationsMixin, ApplicationDefinitionsOperations, ApplicationsOperations, JitRequestsOperations + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential + +class ApplicationClient(ApplicationClientOperationsMixin): + """ARM applications. + + :ivar applications: ApplicationsOperations operations + :vartype applications: + azure.mgmt.managedapplication.v2021_07_01.operations.ApplicationsOperations + :ivar application_definitions: ApplicationDefinitionsOperations operations + :vartype application_definitions: + azure.mgmt.managedapplication.v2021_07_01.operations.ApplicationDefinitionsOperations + :ivar jit_requests: JitRequestsOperations operations + :vartype jit_requests: + azure.mgmt.managedapplication.v2021_07_01.operations.JitRequestsOperations + :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". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + """ + + def __init__( + self, + credential: "TokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = ApplicationClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.applications = ApplicationsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.application_definitions = ApplicationDefinitionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.jit_requests = JitRequestsOperations( + 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: () -> ApplicationClient + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (Any) -> None + self._client.__exit__(*exc_details) diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_07_01/_configuration.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_07_01/_configuration.py new file mode 100644 index 000000000000..5e317a33cc21 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_07_01/_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 ApplicationClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes + """Configuration for ApplicationClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials.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". 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(ApplicationClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2021-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.") + + 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-managedapplication/{}'.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/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_07_01/_metadata.json b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_07_01/_metadata.json new file mode 100644 index 000000000000..e815464a8071 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_07_01/_metadata.json @@ -0,0 +1,123 @@ +{ + "chosen_version": "2021-07-01", + "total_api_version_list": ["2021-07-01"], + "client": { + "name": "ApplicationClient", + "filename": "_application_client", + "description": "ARM applications.", + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": null, + "azure_arm": true, + "has_lro_operations": true, + "client_side_validation": false, + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ApplicationClientConfiguration\"], \"._operations_mixin\": [\"ApplicationClientOperationsMixin\"]}, \"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\": [\"ApplicationClientConfiguration\"], \"._operations_mixin\": [\"ApplicationClientOperationsMixin\"]}, \"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": { + "applications": "ApplicationsOperations", + "application_definitions": "ApplicationDefinitionsOperations", + "jit_requests": "JitRequestsOperations" + }, + "operation_mixins": { + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Iterable\"]}, \"azurecore\": {\"azure.core.paging\": [\"ItemPaged\"]}}, \"regular\": {\"local\": {\".\": [[\"models\", \"_models\"]]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"AsyncIterable\"]}, \"azurecore\": {\"azure.core.async_paging\": [\"AsyncItemPaged\"]}}, \"regular\": {\"local\": {\"..\": [[\"models\", \"_models\"]]}}}", + "operations": { + "list_operations" : { + "sync": { + "signature": "def list_operations(\n self,\n **kwargs # type: Any\n):\n # type: (...) -\u003e Iterable[_models.OperationListResult]\n", + "doc": "\"\"\"Lists all of the available Microsoft.Solutions REST API operations.\n\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: An iterator like instance of either OperationListResult or the result of cls(response)\n:rtype:\n ~azure.core.paging.ItemPaged[~azure.mgmt.managedapplication.v2021_07_01.models.OperationListResult]\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"", + "call": "**kwargs" + }, + "async": { + "coroutine": false, + "signature": "def list_operations(\n self,\n **kwargs: Any\n) -\u003e AsyncIterable[_models.OperationListResult]:\n", + "doc": "\"\"\"Lists all of the available Microsoft.Solutions REST API operations.\n\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: An iterator like instance of either OperationListResult or the result of cls(response)\n:rtype:\n ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.managedapplication.v2021_07_01.models.OperationListResult]\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"", + "call": "**kwargs" + } + } + } + } +} \ No newline at end of file diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_07_01/_patch.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_07_01/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_07_01/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_07_01/_vendor.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_07_01/_vendor.py new file mode 100644 index 000000000000..bf1845cabc0f --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_07_01/_vendor.py @@ -0,0 +1,45 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from abc import ABC +from typing import TYPE_CHECKING + +from azure.core.pipeline.transport import HttpRequest + +from ._configuration import ApplicationClientConfiguration + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from msrest import Deserializer, Serializer + + from azure.core import PipelineClient + +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) + +class MixinABC(ABC): + """DO NOT use this class. It is for internal typing use only.""" + _client: "PipelineClient" + _config: ApplicationClientConfiguration + _serialize: "Serializer" + _deserialize: "Deserializer" diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_07_01/_version.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_07_01/_version.py new file mode 100644 index 000000000000..e5754a47ce68 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_07_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/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_07_01/aio/__init__.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_07_01/aio/__init__.py new file mode 100644 index 000000000000..c90626a31421 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_07_01/aio/__init__.py @@ -0,0 +1,20 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._application_client import ApplicationClient + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk +__all__ = ['ApplicationClient'] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_07_01/aio/_application_client.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_07_01/aio/_application_client.py new file mode 100644 index 000000000000..5063d5a4c089 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_07_01/aio/_application_client.py @@ -0,0 +1,109 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# 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 ApplicationClientConfiguration +from .operations import ApplicationClientOperationsMixin, ApplicationDefinitionsOperations, ApplicationsOperations, JitRequestsOperations + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + +class ApplicationClient(ApplicationClientOperationsMixin): + """ARM applications. + + :ivar applications: ApplicationsOperations operations + :vartype applications: + azure.mgmt.managedapplication.v2021_07_01.aio.operations.ApplicationsOperations + :ivar application_definitions: ApplicationDefinitionsOperations operations + :vartype application_definitions: + azure.mgmt.managedapplication.v2021_07_01.aio.operations.ApplicationDefinitionsOperations + :ivar jit_requests: JitRequestsOperations operations + :vartype jit_requests: + azure.mgmt.managedapplication.v2021_07_01.aio.operations.JitRequestsOperations + :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". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = ApplicationClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.applications = ApplicationsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.application_definitions = ApplicationDefinitionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.jit_requests = JitRequestsOperations( + 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) -> "ApplicationClient": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_07_01/aio/_configuration.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_07_01/aio/_configuration.py new file mode 100644 index 000000000000..b6c65bf050ea --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_07_01/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 ApplicationClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes + """Configuration for ApplicationClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :param subscription_id: The ID of the target subscription. + :type subscription_id: str + :keyword api_version: Api Version. Default value is "2021-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, + **kwargs: Any + ) -> None: + super(ApplicationClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2021-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.") + + 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-managedapplication/{}'.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/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_07_01/aio/_patch.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_07_01/aio/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_07_01/aio/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_07_01/aio/_vendor.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_07_01/aio/_vendor.py new file mode 100644 index 000000000000..da14e4f71f0e --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_07_01/aio/_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 abc import ABC +from typing import TYPE_CHECKING + +from azure.core.pipeline.transport import HttpRequest + +from ._configuration import ApplicationClientConfiguration + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from msrest import Deserializer, Serializer + + from azure.core import AsyncPipelineClient + + +class MixinABC(ABC): + """DO NOT use this class. It is for internal typing use only.""" + _client: "AsyncPipelineClient" + _config: ApplicationClientConfiguration + _serialize: "Serializer" + _deserialize: "Deserializer" diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_07_01/aio/operations/__init__.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_07_01/aio/operations/__init__.py new file mode 100644 index 000000000000..b93ecbbe65e2 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_07_01/aio/operations/__init__.py @@ -0,0 +1,24 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._application_client_operations import ApplicationClientOperationsMixin +from ._applications_operations import ApplicationsOperations +from ._application_definitions_operations import ApplicationDefinitionsOperations +from ._jit_requests_operations import JitRequestsOperations + +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk +__all__ = [ + 'ApplicationClientOperationsMixin', + 'ApplicationsOperations', + 'ApplicationDefinitionsOperations', + 'JitRequestsOperations', +] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_07_01/aio/operations/_application_client_operations.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_07_01/aio/operations/_application_client_operations.py new file mode 100644 index 000000000000..a2372652556b --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_07_01/aio/operations/_application_client_operations.py @@ -0,0 +1,105 @@ +# 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.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._application_client_operations import build_list_operations_request +from .._vendor import MixinABC +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class ApplicationClientOperationsMixin(MixinABC): + + @distributed_trace + def list_operations( + self, + **kwargs: Any + ) -> AsyncIterable[_models.OperationListResult]: + """Lists all of the available Microsoft.Solutions REST API operations. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either OperationListResult or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.managedapplication.v2021_07_01.models.OperationListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # 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', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_operations_request( + api_version=api_version, + template_url=self.list_operations.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_operations_request( + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list_operations.metadata = {'url': "/providers/Microsoft.Solutions/operations"} # type: ignore diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_07_01/aio/operations/_application_definitions_operations.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_07_01/aio/operations/_application_definitions_operations.py new file mode 100644 index 000000000000..d5aff0e5d2bd --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_07_01/aio/operations/_application_definitions_operations.py @@ -0,0 +1,761 @@ +# 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.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._application_definitions_operations import build_create_or_update_by_id_request, build_create_or_update_request, build_delete_by_id_request, build_delete_request, build_get_by_id_request, build_get_request, build_list_by_resource_group_request, build_list_by_subscription_request, build_update_by_id_request, build_update_request +from .._vendor import MixinABC +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class ApplicationDefinitionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.managedapplication.v2021_07_01.aio.ApplicationClient`'s + :attr:`application_definitions` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + application_definition_name: str, + **kwargs: Any + ) -> Optional[_models.ApplicationDefinition]: + """Gets the managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. + :type application_definition_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ApplicationDefinition, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2021_07_01.models.ApplicationDefinition or None + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.ApplicationDefinition]] + + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('ApplicationDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore + + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + application_definition_name: str, + **kwargs: Any + ) -> None: + """Deletes the managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. + :type application_definition_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + api_version=api_version, + template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore + + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + application_definition_name: str, + parameters: _models.ApplicationDefinition, + **kwargs: Any + ) -> _models.ApplicationDefinition: + """Creates or updates a managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. + :type application_definition_name: str + :param parameters: Parameters supplied to the create or update an managed application + definition. + :type parameters: ~azure.mgmt.managedapplication.v2021_07_01.models.ApplicationDefinition + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ApplicationDefinition, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2021_07_01.models.ApplicationDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationDefinition] + + _json = self._serialize.body(parameters, 'ApplicationDefinition') + + request = build_create_or_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # 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, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('ApplicationDefinition', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('ApplicationDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore + + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + application_definition_name: str, + parameters: _models.ApplicationDefinitionPatchable, + **kwargs: Any + ) -> _models.ApplicationDefinition: + """Updates the managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. + :type application_definition_name: str + :param parameters: Parameters supplied to the update a managed application definition. + :type parameters: + ~azure.mgmt.managedapplication.v2021_07_01.models.ApplicationDefinitionPatchable + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ApplicationDefinition, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2021_07_01.models.ApplicationDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationDefinition] + + _json = self._serialize.body(parameters, 'ApplicationDefinitionPatchable') + + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ApplicationDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore + + + @distributed_trace + def list_by_resource_group( + self, + resource_group_name: str, + **kwargs: Any + ) -> AsyncIterable[_models.ApplicationDefinitionListResult]: + """Lists the managed application definitions in a resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ApplicationDefinitionListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.managedapplication.v2021_07_01.models.ApplicationDefinitionListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationDefinitionListResult] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + api_version=api_version, + template_url=self.list_by_resource_group.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ApplicationDefinitionListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions"} # type: ignore + + @distributed_trace + def list_by_subscription( + self, + **kwargs: Any + ) -> AsyncIterable[_models.ApplicationDefinitionListResult]: + """Lists all the application definitions within a subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ApplicationDefinitionListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.managedapplication.v2021_07_01.models.ApplicationDefinitionListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationDefinitionListResult] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ApplicationDefinitionListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Solutions/applicationDefinitions"} # type: ignore + + @distributed_trace_async + async def get_by_id( + self, + resource_group_name: str, + application_definition_name: str, + **kwargs: Any + ) -> Optional[_models.ApplicationDefinition]: + """Gets the managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. + :type application_definition_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ApplicationDefinition, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2021_07_01.models.ApplicationDefinition or None + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.ApplicationDefinition]] + + + request = build_get_by_id_request( + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_by_id.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('ApplicationDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_by_id.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore + + + @distributed_trace_async + async def delete_by_id( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + application_definition_name: str, + **kwargs: Any + ) -> None: + """Deletes the managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. + :type application_definition_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_by_id_request( + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete_by_id.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete_by_id.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore + + + @distributed_trace_async + async def create_or_update_by_id( + self, + resource_group_name: str, + application_definition_name: str, + parameters: _models.ApplicationDefinition, + **kwargs: Any + ) -> _models.ApplicationDefinition: + """Creates or updates a managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. + :type application_definition_name: str + :param parameters: Parameters supplied to the create or update a managed application + definition. + :type parameters: ~azure.mgmt.managedapplication.v2021_07_01.models.ApplicationDefinition + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ApplicationDefinition, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2021_07_01.models.ApplicationDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationDefinition] + + _json = self._serialize.body(parameters, 'ApplicationDefinition') + + request = build_create_or_update_by_id_request( + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + 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'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # 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, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('ApplicationDefinition', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('ApplicationDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_or_update_by_id.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore + + + @distributed_trace_async + async def update_by_id( + self, + resource_group_name: str, + application_definition_name: str, + parameters: _models.ApplicationDefinitionPatchable, + **kwargs: Any + ) -> _models.ApplicationDefinition: + """Updates the managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. + :type application_definition_name: str + :param parameters: Parameters supplied to the update a managed application definition. + :type parameters: + ~azure.mgmt.managedapplication.v2021_07_01.models.ApplicationDefinitionPatchable + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ApplicationDefinition, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2021_07_01.models.ApplicationDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationDefinition] + + _json = self._serialize.body(parameters, 'ApplicationDefinitionPatchable') + + request = build_update_by_id_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.update_by_id.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ApplicationDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + update_by_id.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore + diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_07_01/aio/operations/_applications_operations.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_07_01/aio/operations/_applications_operations.py new file mode 100644 index 000000000000..eb393ef097c2 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_07_01/aio/operations/_applications_operations.py @@ -0,0 +1,1545 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union, cast + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._applications_operations import build_create_or_update_by_id_request_initial, build_create_or_update_request_initial, build_delete_by_id_request_initial, build_delete_request_initial, build_get_by_id_request, build_get_request, build_list_allowed_upgrade_plans_request, build_list_by_resource_group_request, build_list_by_subscription_request, build_list_tokens_request, build_refresh_permissions_request_initial, build_update_access_request_initial, build_update_by_id_request_initial, build_update_request_initial +from .._vendor import MixinABC +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class ApplicationsOperations: # pylint: disable=too-many-public-methods + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.managedapplication.v2021_07_01.aio.ApplicationClient`'s + :attr:`applications` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + application_name: str, + **kwargs: Any + ) -> Optional[_models.Application]: + """Gets the managed application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_name: The name of the managed application. + :type application_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Application, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2021_07_01.models.Application or None + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.Application]] + + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + application_name=application_name, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('Application', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}"} # type: ignore + + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + application_name: str, + **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + application_name=application_name, + api_version=api_version, + template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}"} # type: ignore + + + @distributed_trace_async + async def begin_delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + application_name: str, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes the managed application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_name: The name of the managed application. + :type application_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._delete_initial( # type: ignore + resource_group_name=resource_group_name, + application_name=application_name, + api_version=api_version, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}"} # type: ignore + + async def _create_or_update_initial( + self, + resource_group_name: str, + application_name: str, + parameters: _models.Application, + **kwargs: Any + ) -> _models.Application: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Application] + + _json = self._serialize.body(parameters, 'Application') + + request = build_create_or_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + application_name=application_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('Application', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('Application', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}"} # type: ignore + + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + application_name: str, + parameters: _models.Application, + **kwargs: Any + ) -> AsyncLROPoller[_models.Application]: + """Creates or updates a managed application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_name: The name of the managed application. + :type application_name: str + :param parameters: Parameters supplied to the create or update a managed application. + :type parameters: ~azure.mgmt.managedapplication.v2021_07_01.models.Application + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either Application or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.managedapplication.v2021_07_01.models.Application] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Application] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._create_or_update_initial( # type: ignore + resource_group_name=resource_group_name, + application_name=application_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('Application', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}"} # type: ignore + + async def _update_initial( + self, + resource_group_name: str, + application_name: str, + parameters: Optional[_models.ApplicationPatchable] = None, + **kwargs: Any + ) -> _models.ApplicationPatchable: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationPatchable] + + if parameters is not None: + _json = self._serialize.body(parameters, 'ApplicationPatchable') + else: + _json = None + + request = build_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + application_name=application_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('ApplicationPatchable', pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize('ApplicationPatchable', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}"} # type: ignore + + + @distributed_trace_async + async def begin_update( + self, + resource_group_name: str, + application_name: str, + parameters: Optional[_models.ApplicationPatchable] = None, + **kwargs: Any + ) -> AsyncLROPoller[_models.ApplicationPatchable]: + """Updates an existing managed application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_name: The name of the managed application. + :type application_name: str + :param parameters: Parameters supplied to update an existing managed application. Default value + is None. + :type parameters: ~azure.mgmt.managedapplication.v2021_07_01.models.ApplicationPatchable + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ApplicationPatchable or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.managedapplication.v2021_07_01.models.ApplicationPatchable] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationPatchable] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._update_initial( # type: ignore + resource_group_name=resource_group_name, + application_name=application_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('ApplicationPatchable', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}"} # type: ignore + + @distributed_trace + def list_by_resource_group( + self, + resource_group_name: str, + **kwargs: Any + ) -> AsyncIterable[_models.ApplicationListResult]: + """Lists all the applications within a resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ApplicationListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.managedapplication.v2021_07_01.models.ApplicationListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationListResult] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + api_version=api_version, + template_url=self.list_by_resource_group.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ApplicationListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications"} # type: ignore + + @distributed_trace + def list_by_subscription( + self, + **kwargs: Any + ) -> AsyncIterable[_models.ApplicationListResult]: + """Lists all the applications within a subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ApplicationListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.managedapplication.v2021_07_01.models.ApplicationListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationListResult] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ApplicationListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Solutions/applications"} # type: ignore + + @distributed_trace_async + async def get_by_id( + self, + application_id: str, + **kwargs: Any + ) -> Optional[_models.Application]: + """Gets the managed application. + + :param application_id: The fully qualified ID of the managed application, including the managed + application name and the managed application resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/Microsoft.Solutions/applications/{application-name}. + :type application_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Application, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2021_07_01.models.Application or None + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.Application]] + + + request = build_get_by_id_request( + application_id=application_id, + api_version=api_version, + template_url=self.get_by_id.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('Application', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_by_id.metadata = {'url': "/{applicationId}"} # type: ignore + + + async def _delete_by_id_initial( # pylint: disable=inconsistent-return-statements + self, + application_id: str, + **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_by_id_request_initial( + application_id=application_id, + api_version=api_version, + template_url=self._delete_by_id_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_by_id_initial.metadata = {'url': "/{applicationId}"} # type: ignore + + + @distributed_trace_async + async def begin_delete_by_id( # pylint: disable=inconsistent-return-statements + self, + application_id: str, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes the managed application. + + :param application_id: The fully qualified ID of the managed application, including the managed + application name and the managed application resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/Microsoft.Solutions/applications/{application-name}. + :type application_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._delete_by_id_initial( # type: ignore + application_id=application_id, + api_version=api_version, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete_by_id.metadata = {'url': "/{applicationId}"} # type: ignore + + async def _create_or_update_by_id_initial( + self, + application_id: str, + parameters: _models.Application, + **kwargs: Any + ) -> _models.Application: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Application] + + _json = self._serialize.body(parameters, 'Application') + + request = build_create_or_update_by_id_request_initial( + application_id=application_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._create_or_update_by_id_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('Application', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('Application', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_by_id_initial.metadata = {'url': "/{applicationId}"} # type: ignore + + + @distributed_trace_async + async def begin_create_or_update_by_id( + self, + application_id: str, + parameters: _models.Application, + **kwargs: Any + ) -> AsyncLROPoller[_models.Application]: + """Creates or updates a managed application. + + :param application_id: The fully qualified ID of the managed application, including the managed + application name and the managed application resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/Microsoft.Solutions/applications/{application-name}. + :type application_id: str + :param parameters: Parameters supplied to the create or update a managed application. + :type parameters: ~azure.mgmt.managedapplication.v2021_07_01.models.Application + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either Application or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.managedapplication.v2021_07_01.models.Application] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Application] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._create_or_update_by_id_initial( # type: ignore + application_id=application_id, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('Application', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update_by_id.metadata = {'url': "/{applicationId}"} # type: ignore + + async def _update_by_id_initial( + self, + application_id: str, + parameters: Optional[_models.ApplicationPatchable] = None, + **kwargs: Any + ) -> _models.ApplicationPatchable: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationPatchable] + + if parameters is not None: + _json = self._serialize.body(parameters, 'ApplicationPatchable') + else: + _json = None + + request = build_update_by_id_request_initial( + application_id=application_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._update_by_id_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('ApplicationPatchable', pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize('ApplicationPatchable', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _update_by_id_initial.metadata = {'url': "/{applicationId}"} # type: ignore + + + @distributed_trace_async + async def begin_update_by_id( + self, + application_id: str, + parameters: Optional[_models.ApplicationPatchable] = None, + **kwargs: Any + ) -> AsyncLROPoller[_models.ApplicationPatchable]: + """Updates an existing managed application. + + :param application_id: The fully qualified ID of the managed application, including the managed + application name and the managed application resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/Microsoft.Solutions/applications/{application-name}. + :type application_id: str + :param parameters: Parameters supplied to update an existing managed application. Default value + is None. + :type parameters: ~azure.mgmt.managedapplication.v2021_07_01.models.ApplicationPatchable + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ApplicationPatchable or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.managedapplication.v2021_07_01.models.ApplicationPatchable] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationPatchable] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._update_by_id_initial( # type: ignore + application_id=application_id, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('ApplicationPatchable', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_update_by_id.metadata = {'url': "/{applicationId}"} # type: ignore + + async def _refresh_permissions_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + application_name: str, + **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_refresh_permissions_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + application_name=application_name, + api_version=api_version, + template_url=self._refresh_permissions_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _refresh_permissions_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}/refreshPermissions"} # type: ignore + + + @distributed_trace_async + async def begin_refresh_permissions( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + application_name: str, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Refresh Permissions for application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_name: The name of the managed application. + :type application_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._refresh_permissions_initial( # type: ignore + resource_group_name=resource_group_name, + application_name=application_name, + api_version=api_version, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'location'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_refresh_permissions.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}/refreshPermissions"} # type: ignore + + @distributed_trace_async + async def list_allowed_upgrade_plans( + self, + resource_group_name: str, + application_name: str, + **kwargs: Any + ) -> _models.AllowedUpgradePlansResult: + """List allowed upgrade plans for application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_name: The name of the managed application. + :type application_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AllowedUpgradePlansResult, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2021_07_01.models.AllowedUpgradePlansResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AllowedUpgradePlansResult] + + + request = build_list_allowed_upgrade_plans_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + application_name=application_name, + api_version=api_version, + template_url=self.list_allowed_upgrade_plans.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('AllowedUpgradePlansResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_allowed_upgrade_plans.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}/listAllowedUpgradePlans"} # type: ignore + + + async def _update_access_initial( + self, + resource_group_name: str, + application_name: str, + parameters: _models.UpdateAccessDefinition, + **kwargs: Any + ) -> Optional[_models.UpdateAccessDefinition]: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.UpdateAccessDefinition]] + + _json = self._serialize.body(parameters, 'UpdateAccessDefinition') + + request = build_update_access_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + application_name=application_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._update_access_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 202: + deserialized = self._deserialize('UpdateAccessDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _update_access_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}/updateAccess"} # type: ignore + + + @distributed_trace_async + async def begin_update_access( + self, + resource_group_name: str, + application_name: str, + parameters: _models.UpdateAccessDefinition, + **kwargs: Any + ) -> AsyncLROPoller[_models.UpdateAccessDefinition]: + """Update access for application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_name: The name of the managed application. + :type application_name: str + :param parameters: Request body parameters to list tokens. + :type parameters: ~azure.mgmt.managedapplication.v2021_07_01.models.UpdateAccessDefinition + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either UpdateAccessDefinition or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.managedapplication.v2021_07_01.models.UpdateAccessDefinition] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.UpdateAccessDefinition] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._update_access_initial( # type: ignore + resource_group_name=resource_group_name, + application_name=application_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('UpdateAccessDefinition', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'location'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_update_access.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}/updateAccess"} # type: ignore + + @distributed_trace_async + async def list_tokens( + self, + resource_group_name: str, + application_name: str, + parameters: _models.ListTokenRequest, + **kwargs: Any + ) -> _models.ManagedIdentityTokenResult: + """List tokens for application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_name: The name of the managed application. + :type application_name: str + :param parameters: Request body parameters to list tokens. + :type parameters: ~azure.mgmt.managedapplication.v2021_07_01.models.ListTokenRequest + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ManagedIdentityTokenResult, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2021_07_01.models.ManagedIdentityTokenResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ManagedIdentityTokenResult] + + _json = self._serialize.body(parameters, 'ListTokenRequest') + + request = build_list_tokens_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + application_name=application_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.list_tokens.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ManagedIdentityTokenResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_tokens.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}/listTokens"} # type: ignore + diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_07_01/aio/operations/_jit_requests_operations.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_07_01/aio/operations/_jit_requests_operations.py new file mode 100644 index 000000000000..3df9e9245b2f --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_07_01/aio/operations/_jit_requests_operations.py @@ -0,0 +1,502 @@ +# 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, Union, cast + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._jit_requests_operations import build_create_or_update_request_initial, build_delete_request, build_get_request, build_list_by_resource_group_request, build_list_by_subscription_request, build_update_request +from .._vendor import MixinABC +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class JitRequestsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.managedapplication.v2021_07_01.aio.ApplicationClient`'s + :attr:`jit_requests` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + jit_request_name: str, + **kwargs: Any + ) -> Optional[_models.JitRequestDefinition]: + """Gets the JIT request. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param jit_request_name: The name of the JIT request. + :type jit_request_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JitRequestDefinition, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2021_07_01.models.JitRequestDefinition or None + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.JitRequestDefinition]] + + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + jit_request_name=jit_request_name, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('JitRequestDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/jitRequests/{jitRequestName}"} # type: ignore + + + async def _create_or_update_initial( + self, + resource_group_name: str, + jit_request_name: str, + parameters: _models.JitRequestDefinition, + **kwargs: Any + ) -> _models.JitRequestDefinition: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.JitRequestDefinition] + + _json = self._serialize.body(parameters, 'JitRequestDefinition') + + request = build_create_or_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + jit_request_name=jit_request_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('JitRequestDefinition', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('JitRequestDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/jitRequests/{jitRequestName}"} # type: ignore + + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + jit_request_name: str, + parameters: _models.JitRequestDefinition, + **kwargs: Any + ) -> AsyncLROPoller[_models.JitRequestDefinition]: + """Creates or updates the JIT request. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param jit_request_name: The name of the JIT request. + :type jit_request_name: str + :param parameters: Parameters supplied to the update JIT request. + :type parameters: ~azure.mgmt.managedapplication.v2021_07_01.models.JitRequestDefinition + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either JitRequestDefinition or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.managedapplication.v2021_07_01.models.JitRequestDefinition] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.JitRequestDefinition] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._create_or_update_initial( # type: ignore + resource_group_name=resource_group_name, + jit_request_name=jit_request_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('JitRequestDefinition', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/jitRequests/{jitRequestName}"} # type: ignore + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + jit_request_name: str, + parameters: _models.JitRequestPatchable, + **kwargs: Any + ) -> _models.JitRequestDefinition: + """Updates the JIT request. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param jit_request_name: The name of the JIT request. + :type jit_request_name: str + :param parameters: Parameters supplied to the update JIT request. + :type parameters: ~azure.mgmt.managedapplication.v2021_07_01.models.JitRequestPatchable + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JitRequestDefinition, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2021_07_01.models.JitRequestDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.JitRequestDefinition] + + _json = self._serialize.body(parameters, 'JitRequestPatchable') + + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + jit_request_name=jit_request_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('JitRequestDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/jitRequests/{jitRequestName}"} # type: ignore + + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + jit_request_name: str, + **kwargs: Any + ) -> None: + """Deletes the JIT request. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param jit_request_name: The name of the JIT request. + :type jit_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 + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + jit_request_name=jit_request_name, + api_version=api_version, + template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/jitRequests/{jitRequestName}"} # type: ignore + + + @distributed_trace_async + async def list_by_subscription( + self, + **kwargs: Any + ) -> _models.JitRequestDefinitionListResult: + """Lists all JIT requests within the subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JitRequestDefinitionListResult, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2021_07_01.models.JitRequestDefinitionListResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.JitRequestDefinitionListResult] + + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('JitRequestDefinitionListResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Solutions/jitRequests"} # type: ignore + + + @distributed_trace_async + async def list_by_resource_group( + self, + resource_group_name: str, + **kwargs: Any + ) -> _models.JitRequestDefinitionListResult: + """Lists all JIT requests within the 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: JitRequestDefinitionListResult, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2021_07_01.models.JitRequestDefinitionListResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.JitRequestDefinitionListResult] + + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + api_version=api_version, + template_url=self.list_by_resource_group.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('JitRequestDefinitionListResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/jitRequests"} # type: ignore + diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_07_01/aio/operations/_patch.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_07_01/aio/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_07_01/aio/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_07_01/models/__init__.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_07_01/models/__init__.py new file mode 100644 index 000000000000..68db0a00c735 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_07_01/models/__init__.py @@ -0,0 +1,145 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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 AllowedUpgradePlansResult +from ._models_py3 import Application +from ._models_py3 import ApplicationArtifact +from ._models_py3 import ApplicationAuthorization +from ._models_py3 import ApplicationBillingDetailsDefinition +from ._models_py3 import ApplicationClientDetails +from ._models_py3 import ApplicationDefinition +from ._models_py3 import ApplicationDefinitionArtifact +from ._models_py3 import ApplicationDefinitionListResult +from ._models_py3 import ApplicationDefinitionPatchable +from ._models_py3 import ApplicationDeploymentPolicy +from ._models_py3 import ApplicationJitAccessPolicy +from ._models_py3 import ApplicationListResult +from ._models_py3 import ApplicationManagementPolicy +from ._models_py3 import ApplicationNotificationEndpoint +from ._models_py3 import ApplicationNotificationPolicy +from ._models_py3 import ApplicationPackageContact +from ._models_py3 import ApplicationPackageLockingPolicyDefinition +from ._models_py3 import ApplicationPackageSupportUrls +from ._models_py3 import ApplicationPatchable +from ._models_py3 import ApplicationPolicy +from ._models_py3 import ErrorAdditionalInfo +from ._models_py3 import ErrorDetail +from ._models_py3 import ErrorResponse +from ._models_py3 import GenericResource +from ._models_py3 import Identity +from ._models_py3 import JitApproverDefinition +from ._models_py3 import JitAuthorizationPolicies +from ._models_py3 import JitRequestDefinition +from ._models_py3 import JitRequestDefinitionListResult +from ._models_py3 import JitRequestMetadata +from ._models_py3 import JitRequestPatchable +from ._models_py3 import JitSchedulingPolicy +from ._models_py3 import ListTokenRequest +from ._models_py3 import ManagedIdentityToken +from ._models_py3 import ManagedIdentityTokenResult +from ._models_py3 import Operation +from ._models_py3 import OperationDisplay +from ._models_py3 import OperationListResult +from ._models_py3 import Plan +from ._models_py3 import PlanPatchable +from ._models_py3 import Resource +from ._models_py3 import Sku +from ._models_py3 import SystemData +from ._models_py3 import UpdateAccessDefinition +from ._models_py3 import UserAssignedResourceIdentity + + +from ._application_client_enums import ( + ActionType, + ApplicationArtifactName, + ApplicationArtifactType, + ApplicationDefinitionArtifactName, + ApplicationLockLevel, + ApplicationManagementMode, + CreatedByType, + DeploymentMode, + JitApprovalMode, + JitApproverType, + JitRequestState, + JitSchedulingType, + Origin, + ProvisioningState, + ResourceIdentityType, + Status, + Substatus, +) +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk +__all__ = [ + 'AllowedUpgradePlansResult', + 'Application', + 'ApplicationArtifact', + 'ApplicationAuthorization', + 'ApplicationBillingDetailsDefinition', + 'ApplicationClientDetails', + 'ApplicationDefinition', + 'ApplicationDefinitionArtifact', + 'ApplicationDefinitionListResult', + 'ApplicationDefinitionPatchable', + 'ApplicationDeploymentPolicy', + 'ApplicationJitAccessPolicy', + 'ApplicationListResult', + 'ApplicationManagementPolicy', + 'ApplicationNotificationEndpoint', + 'ApplicationNotificationPolicy', + 'ApplicationPackageContact', + 'ApplicationPackageLockingPolicyDefinition', + 'ApplicationPackageSupportUrls', + 'ApplicationPatchable', + 'ApplicationPolicy', + 'ErrorAdditionalInfo', + 'ErrorDetail', + 'ErrorResponse', + 'GenericResource', + 'Identity', + 'JitApproverDefinition', + 'JitAuthorizationPolicies', + 'JitRequestDefinition', + 'JitRequestDefinitionListResult', + 'JitRequestMetadata', + 'JitRequestPatchable', + 'JitSchedulingPolicy', + 'ListTokenRequest', + 'ManagedIdentityToken', + 'ManagedIdentityTokenResult', + 'Operation', + 'OperationDisplay', + 'OperationListResult', + 'Plan', + 'PlanPatchable', + 'Resource', + 'Sku', + 'SystemData', + 'UpdateAccessDefinition', + 'UserAssignedResourceIdentity', + 'ActionType', + 'ApplicationArtifactName', + 'ApplicationArtifactType', + 'ApplicationDefinitionArtifactName', + 'ApplicationLockLevel', + 'ApplicationManagementMode', + 'CreatedByType', + 'DeploymentMode', + 'JitApprovalMode', + 'JitApproverType', + 'JitRequestState', + 'JitSchedulingType', + 'Origin', + 'ProvisioningState', + 'ResourceIdentityType', + 'Status', + 'Substatus', +] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_07_01/models/_application_client_enums.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_07_01/models/_application_client_enums.py new file mode 100644 index 000000000000..2605f40e804c --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_07_01/models/_application_client_enums.py @@ -0,0 +1,163 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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 azure.core import CaseInsensitiveEnumMeta + + +class ActionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. + """ + + INTERNAL = "Internal" + +class ApplicationArtifactName(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The managed application artifact name. + """ + + NOT_SPECIFIED = "NotSpecified" + VIEW_DEFINITION = "ViewDefinition" + AUTHORIZATIONS = "Authorizations" + CUSTOM_ROLE_DEFINITION = "CustomRoleDefinition" + +class ApplicationArtifactType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The managed application artifact type. + """ + + NOT_SPECIFIED = "NotSpecified" + TEMPLATE = "Template" + CUSTOM = "Custom" + +class ApplicationDefinitionArtifactName(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The managed application artifact name. + """ + + NOT_SPECIFIED = "NotSpecified" + APPLICATION_RESOURCE_TEMPLATE = "ApplicationResourceTemplate" + CREATE_UI_DEFINITION = "CreateUiDefinition" + MAIN_TEMPLATE_PARAMETERS = "MainTemplateParameters" + +class ApplicationLockLevel(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The managed application lock level. + """ + + CAN_NOT_DELETE = "CanNotDelete" + READ_ONLY = "ReadOnly" + NONE = "None" + +class ApplicationManagementMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The management mode. + """ + + NOT_SPECIFIED = "NotSpecified" + UNMANAGED = "Unmanaged" + MANAGED = "Managed" + +class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of identity that created the resource. + """ + + USER = "User" + APPLICATION = "Application" + MANAGED_IDENTITY = "ManagedIdentity" + KEY = "Key" + +class DeploymentMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The deployment mode. + """ + + NOT_SPECIFIED = "NotSpecified" + INCREMENTAL = "Incremental" + COMPLETE = "Complete" + +class JitApprovalMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The Jit approval mode. + """ + + NOT_SPECIFIED = "NotSpecified" + AUTO_APPROVE = "AutoApprove" + MANUAL_APPROVE = "ManualApprove" + +class JitApproverType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The approver type. + """ + + USER = "user" + GROUP = "group" + +class JitRequestState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The JIT request state. + """ + + NOT_SPECIFIED = "NotSpecified" + PENDING = "Pending" + APPROVED = "Approved" + DENIED = "Denied" + FAILED = "Failed" + CANCELED = "Canceled" + EXPIRED = "Expired" + TIMEOUT = "Timeout" + +class JitSchedulingType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The JIT request scheduling type. + """ + + NOT_SPECIFIED = "NotSpecified" + ONCE = "Once" + RECURRING = "Recurring" + +class Origin(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit + logs UX. Default value is "user,system" + """ + + USER = "user" + SYSTEM = "system" + USER_SYSTEM = "user,system" + +class ProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Provisioning status of the managed application. + """ + + NOT_SPECIFIED = "NotSpecified" + ACCEPTED = "Accepted" + RUNNING = "Running" + DELETING = "Deleting" + DELETED = "Deleted" + CANCELED = "Canceled" + FAILED = "Failed" + SUCCEEDED = "Succeeded" + UPDATING = "Updating" + +class ResourceIdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The identity type. + """ + + SYSTEM_ASSIGNED = "SystemAssigned" + USER_ASSIGNED = "UserAssigned" + SYSTEM_ASSIGNED_USER_ASSIGNED = "SystemAssigned, UserAssigned" + NONE = "None" + +class Status(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The JIT status. + """ + + NOT_SPECIFIED = "NotSpecified" + ELEVATE = "Elevate" + REMOVE = "Remove" + +class Substatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The sub status. + """ + + NOT_SPECIFIED = "NotSpecified" + APPROVED = "Approved" + DENIED = "Denied" + FAILED = "Failed" + EXPIRED = "Expired" + TIMEOUT = "Timeout" diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_07_01/models/_models_py3.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_07_01/models/_models_py3.py new file mode 100644 index 000000000000..8b943c8f48f8 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_07_01/models/_models_py3.py @@ -0,0 +1,2487 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for 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 Any, Dict, List, Optional, TYPE_CHECKING, Union + +from azure.core.exceptions import HttpResponseError +import msrest.serialization + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + import __init__ as _models + + +class AllowedUpgradePlansResult(msrest.serialization.Model): + """The array of plan. + + :ivar value: The array of plans. + :vartype value: list[~azure.mgmt.managedapplication.v2021_07_01.models.Plan] + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Plan]'}, + } + + def __init__( + self, + *, + value: Optional[List["_models.Plan"]] = None, + **kwargs + ): + """ + :keyword value: The array of plans. + :paramtype value: list[~azure.mgmt.managedapplication.v2021_07_01.models.Plan] + """ + super(AllowedUpgradePlansResult, self).__init__(**kwargs) + self.value = value + + +class Resource(msrest.serialization.Model): + """Resource information. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Resource ID. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar location: Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~azure.mgmt.managedapplication.v2021_07_01.models.SystemData + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'system_data': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'location': {'key': 'location', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + 'system_data': {'key': 'systemData', 'type': 'SystemData'}, + } + + def __init__( + self, + *, + location: Optional[str] = None, + tags: Optional[Dict[str, str]] = None, + **kwargs + ): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + """ + super(Resource, self).__init__(**kwargs) + self.id = None + self.name = None + self.type = None + self.location = location + self.tags = tags + self.system_data = None + + +class GenericResource(Resource): + """Resource information. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Resource ID. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar location: Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~azure.mgmt.managedapplication.v2021_07_01.models.SystemData + :ivar managed_by: ID of the resource that manages this resource. + :vartype managed_by: str + :ivar sku: The SKU of the resource. + :vartype sku: ~azure.mgmt.managedapplication.v2021_07_01.models.Sku + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'system_data': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'location': {'key': 'location', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + 'system_data': {'key': 'systemData', 'type': 'SystemData'}, + 'managed_by': {'key': 'managedBy', 'type': 'str'}, + 'sku': {'key': 'sku', 'type': 'Sku'}, + } + + def __init__( + self, + *, + location: Optional[str] = None, + tags: Optional[Dict[str, str]] = None, + managed_by: Optional[str] = None, + sku: Optional["_models.Sku"] = None, + **kwargs + ): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword managed_by: ID of the resource that manages this resource. + :paramtype managed_by: str + :keyword sku: The SKU of the resource. + :paramtype sku: ~azure.mgmt.managedapplication.v2021_07_01.models.Sku + """ + super(GenericResource, self).__init__(location=location, tags=tags, **kwargs) + self.managed_by = managed_by + self.sku = sku + + +class Application(GenericResource): + """Information about managed application. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar id: Resource ID. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar location: Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~azure.mgmt.managedapplication.v2021_07_01.models.SystemData + :ivar managed_by: ID of the resource that manages this resource. + :vartype managed_by: str + :ivar sku: The SKU of the resource. + :vartype sku: ~azure.mgmt.managedapplication.v2021_07_01.models.Sku + :ivar plan: The plan information. + :vartype plan: ~azure.mgmt.managedapplication.v2021_07_01.models.Plan + :ivar kind: Required. The kind of the managed application. Allowed values are MarketPlace and + ServiceCatalog. + :vartype kind: str + :ivar identity: The identity of the resource. + :vartype identity: ~azure.mgmt.managedapplication.v2021_07_01.models.Identity + :ivar managed_resource_group_id: The managed resource group Id. + :vartype managed_resource_group_id: str + :ivar application_definition_id: The fully qualified path of managed application definition Id. + :vartype application_definition_id: str + :ivar parameters: Name and value pairs that define the managed application parameters. It can + be a JObject or a well formed JSON string. + :vartype parameters: any + :ivar outputs: Name and value pairs that define the managed application outputs. + :vartype outputs: any + :ivar provisioning_state: The managed application provisioning state. Known values are: + "NotSpecified", "Accepted", "Running", "Deleting", "Deleted", "Canceled", "Failed", + "Succeeded", "Updating". + :vartype provisioning_state: str or + ~azure.mgmt.managedapplication.v2021_07_01.models.ProvisioningState + :ivar billing_details: The managed application billing details. + :vartype billing_details: + ~azure.mgmt.managedapplication.v2021_07_01.models.ApplicationBillingDetailsDefinition + :ivar jit_access_policy: The managed application Jit access policy. + :vartype jit_access_policy: + ~azure.mgmt.managedapplication.v2021_07_01.models.ApplicationJitAccessPolicy + :ivar publisher_tenant_id: The publisher tenant Id. + :vartype publisher_tenant_id: str + :ivar authorizations: The read-only authorizations property that is retrieved from the + application package. + :vartype authorizations: + list[~azure.mgmt.managedapplication.v2021_07_01.models.ApplicationAuthorization] + :ivar management_mode: The managed application management mode. Known values are: + "NotSpecified", "Unmanaged", "Managed". + :vartype management_mode: str or + ~azure.mgmt.managedapplication.v2021_07_01.models.ApplicationManagementMode + :ivar customer_support: The read-only customer support property that is retrieved from the + application package. + :vartype customer_support: + ~azure.mgmt.managedapplication.v2021_07_01.models.ApplicationPackageContact + :ivar support_urls: The read-only support URLs property that is retrieved from the application + package. + :vartype support_urls: + ~azure.mgmt.managedapplication.v2021_07_01.models.ApplicationPackageSupportUrls + :ivar artifacts: The collection of managed application artifacts. + :vartype artifacts: list[~azure.mgmt.managedapplication.v2021_07_01.models.ApplicationArtifact] + :ivar created_by: The client entity that created the JIT request. + :vartype created_by: ~azure.mgmt.managedapplication.v2021_07_01.models.ApplicationClientDetails + :ivar updated_by: The client entity that last updated the JIT request. + :vartype updated_by: ~azure.mgmt.managedapplication.v2021_07_01.models.ApplicationClientDetails + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'system_data': {'readonly': True}, + 'kind': {'required': True, 'pattern': r'^[-\w\._,\(\)]+$'}, + 'outputs': {'readonly': True}, + 'provisioning_state': {'readonly': True}, + 'billing_details': {'readonly': True}, + 'publisher_tenant_id': {'readonly': True}, + 'authorizations': {'readonly': True}, + 'management_mode': {'readonly': True}, + 'customer_support': {'readonly': True}, + 'support_urls': {'readonly': True}, + 'artifacts': {'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'}, + 'location': {'key': 'location', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + 'system_data': {'key': 'systemData', 'type': 'SystemData'}, + 'managed_by': {'key': 'managedBy', 'type': 'str'}, + 'sku': {'key': 'sku', 'type': 'Sku'}, + 'plan': {'key': 'plan', 'type': 'Plan'}, + 'kind': {'key': 'kind', 'type': 'str'}, + 'identity': {'key': 'identity', 'type': 'Identity'}, + 'managed_resource_group_id': {'key': 'properties.managedResourceGroupId', 'type': 'str'}, + 'application_definition_id': {'key': 'properties.applicationDefinitionId', 'type': 'str'}, + 'parameters': {'key': 'properties.parameters', 'type': 'object'}, + 'outputs': {'key': 'properties.outputs', 'type': 'object'}, + 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + 'billing_details': {'key': 'properties.billingDetails', 'type': 'ApplicationBillingDetailsDefinition'}, + 'jit_access_policy': {'key': 'properties.jitAccessPolicy', 'type': 'ApplicationJitAccessPolicy'}, + 'publisher_tenant_id': {'key': 'properties.publisherTenantId', 'type': 'str'}, + 'authorizations': {'key': 'properties.authorizations', 'type': '[ApplicationAuthorization]'}, + 'management_mode': {'key': 'properties.managementMode', 'type': 'str'}, + 'customer_support': {'key': 'properties.customerSupport', 'type': 'ApplicationPackageContact'}, + 'support_urls': {'key': 'properties.supportUrls', 'type': 'ApplicationPackageSupportUrls'}, + 'artifacts': {'key': 'properties.artifacts', 'type': '[ApplicationArtifact]'}, + 'created_by': {'key': 'properties.createdBy', 'type': 'ApplicationClientDetails'}, + 'updated_by': {'key': 'properties.updatedBy', 'type': 'ApplicationClientDetails'}, + } + + def __init__( + self, + *, + kind: str, + location: Optional[str] = None, + tags: Optional[Dict[str, str]] = None, + managed_by: Optional[str] = None, + sku: Optional["_models.Sku"] = None, + plan: Optional["_models.Plan"] = None, + identity: Optional["_models.Identity"] = None, + managed_resource_group_id: Optional[str] = None, + application_definition_id: Optional[str] = None, + parameters: Optional[Any] = None, + jit_access_policy: Optional["_models.ApplicationJitAccessPolicy"] = None, + **kwargs + ): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword managed_by: ID of the resource that manages this resource. + :paramtype managed_by: str + :keyword sku: The SKU of the resource. + :paramtype sku: ~azure.mgmt.managedapplication.v2021_07_01.models.Sku + :keyword plan: The plan information. + :paramtype plan: ~azure.mgmt.managedapplication.v2021_07_01.models.Plan + :keyword kind: Required. The kind of the managed application. Allowed values are MarketPlace + and ServiceCatalog. + :paramtype kind: str + :keyword identity: The identity of the resource. + :paramtype identity: ~azure.mgmt.managedapplication.v2021_07_01.models.Identity + :keyword managed_resource_group_id: The managed resource group Id. + :paramtype managed_resource_group_id: str + :keyword application_definition_id: The fully qualified path of managed application definition + Id. + :paramtype application_definition_id: str + :keyword parameters: Name and value pairs that define the managed application parameters. It + can be a JObject or a well formed JSON string. + :paramtype parameters: any + :keyword jit_access_policy: The managed application Jit access policy. + :paramtype jit_access_policy: + ~azure.mgmt.managedapplication.v2021_07_01.models.ApplicationJitAccessPolicy + """ + super(Application, self).__init__(location=location, tags=tags, managed_by=managed_by, sku=sku, **kwargs) + self.plan = plan + self.kind = kind + self.identity = identity + self.managed_resource_group_id = managed_resource_group_id + self.application_definition_id = application_definition_id + self.parameters = parameters + self.outputs = None + self.provisioning_state = None + self.billing_details = None + self.jit_access_policy = jit_access_policy + self.publisher_tenant_id = None + self.authorizations = None + self.management_mode = None + self.customer_support = None + self.support_urls = None + self.artifacts = None + self.created_by = None + self.updated_by = None + + +class ApplicationArtifact(msrest.serialization.Model): + """Managed application artifact. + + All required parameters must be populated in order to send to Azure. + + :ivar name: Required. The managed application artifact name. Known values are: "NotSpecified", + "ViewDefinition", "Authorizations", "CustomRoleDefinition". + :vartype name: str or ~azure.mgmt.managedapplication.v2021_07_01.models.ApplicationArtifactName + :ivar uri: Required. The managed application artifact blob uri. + :vartype uri: str + :ivar type: Required. The managed application artifact type. Known values are: "NotSpecified", + "Template", "Custom". + :vartype type: str or ~azure.mgmt.managedapplication.v2021_07_01.models.ApplicationArtifactType + """ + + _validation = { + 'name': {'required': True}, + 'uri': {'required': True}, + 'type': {'required': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'uri': {'key': 'uri', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + } + + def __init__( + self, + *, + name: Union[str, "_models.ApplicationArtifactName"], + uri: str, + type: Union[str, "_models.ApplicationArtifactType"], + **kwargs + ): + """ + :keyword name: Required. The managed application artifact name. Known values are: + "NotSpecified", "ViewDefinition", "Authorizations", "CustomRoleDefinition". + :paramtype name: str or + ~azure.mgmt.managedapplication.v2021_07_01.models.ApplicationArtifactName + :keyword uri: Required. The managed application artifact blob uri. + :paramtype uri: str + :keyword type: Required. The managed application artifact type. Known values are: + "NotSpecified", "Template", "Custom". + :paramtype type: str or + ~azure.mgmt.managedapplication.v2021_07_01.models.ApplicationArtifactType + """ + super(ApplicationArtifact, self).__init__(**kwargs) + self.name = name + self.uri = uri + self.type = type + + +class ApplicationAuthorization(msrest.serialization.Model): + """The managed application provider authorization. + + All required parameters must be populated in order to send to Azure. + + :ivar principal_id: Required. The provider's principal identifier. This is the identity that + the provider will use to call ARM to manage the managed application resources. + :vartype principal_id: str + :ivar role_definition_id: Required. The provider's role definition identifier. This role will + define all the permissions that the provider must have on the managed application's container + resource group. This role definition cannot have permission to delete the resource group. + :vartype role_definition_id: str + """ + + _validation = { + 'principal_id': {'required': True}, + 'role_definition_id': {'required': True}, + } + + _attribute_map = { + 'principal_id': {'key': 'principalId', 'type': 'str'}, + 'role_definition_id': {'key': 'roleDefinitionId', 'type': 'str'}, + } + + def __init__( + self, + *, + principal_id: str, + role_definition_id: str, + **kwargs + ): + """ + :keyword principal_id: Required. The provider's principal identifier. This is the identity that + the provider will use to call ARM to manage the managed application resources. + :paramtype principal_id: str + :keyword role_definition_id: Required. The provider's role definition identifier. This role + will define all the permissions that the provider must have on the managed application's + container resource group. This role definition cannot have permission to delete the resource + group. + :paramtype role_definition_id: str + """ + super(ApplicationAuthorization, self).__init__(**kwargs) + self.principal_id = principal_id + self.role_definition_id = role_definition_id + + +class ApplicationBillingDetailsDefinition(msrest.serialization.Model): + """Managed application billing details definition. + + :ivar resource_usage_id: The managed application resource usage Id. + :vartype resource_usage_id: str + """ + + _attribute_map = { + 'resource_usage_id': {'key': 'resourceUsageId', 'type': 'str'}, + } + + def __init__( + self, + *, + resource_usage_id: Optional[str] = None, + **kwargs + ): + """ + :keyword resource_usage_id: The managed application resource usage Id. + :paramtype resource_usage_id: str + """ + super(ApplicationBillingDetailsDefinition, self).__init__(**kwargs) + self.resource_usage_id = resource_usage_id + + +class ApplicationClientDetails(msrest.serialization.Model): + """The application client details to track the entity creating/updating the managed app resource. + + :ivar oid: The client Oid. + :vartype oid: str + :ivar puid: The client Puid. + :vartype puid: str + :ivar application_id: The client application Id. + :vartype application_id: str + """ + + _attribute_map = { + 'oid': {'key': 'oid', 'type': 'str'}, + 'puid': {'key': 'puid', 'type': 'str'}, + 'application_id': {'key': 'applicationId', 'type': 'str'}, + } + + def __init__( + self, + *, + oid: Optional[str] = None, + puid: Optional[str] = None, + application_id: Optional[str] = None, + **kwargs + ): + """ + :keyword oid: The client Oid. + :paramtype oid: str + :keyword puid: The client Puid. + :paramtype puid: str + :keyword application_id: The client application Id. + :paramtype application_id: str + """ + super(ApplicationClientDetails, self).__init__(**kwargs) + self.oid = oid + self.puid = puid + self.application_id = application_id + + +class ApplicationDefinition(GenericResource): + """Information about managed application definition. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar id: Resource ID. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar location: Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~azure.mgmt.managedapplication.v2021_07_01.models.SystemData + :ivar managed_by: ID of the resource that manages this resource. + :vartype managed_by: str + :ivar sku: The SKU of the resource. + :vartype sku: ~azure.mgmt.managedapplication.v2021_07_01.models.Sku + :ivar lock_level: Required. The managed application lock level. Known values are: + "CanNotDelete", "ReadOnly", "None". + :vartype lock_level: str or + ~azure.mgmt.managedapplication.v2021_07_01.models.ApplicationLockLevel + :ivar display_name: The managed application definition display name. + :vartype display_name: str + :ivar is_enabled: A value indicating whether the package is enabled or not. + :vartype is_enabled: bool + :ivar authorizations: The managed application provider authorizations. + :vartype authorizations: + list[~azure.mgmt.managedapplication.v2021_07_01.models.ApplicationAuthorization] + :ivar artifacts: The collection of managed application artifacts. The portal will use the files + specified as artifacts to construct the user experience of creating a managed application from + a managed application definition. + :vartype artifacts: + list[~azure.mgmt.managedapplication.v2021_07_01.models.ApplicationDefinitionArtifact] + :ivar description: The managed application definition description. + :vartype description: str + :ivar package_file_uri: The managed application definition package file Uri. Use this element. + :vartype package_file_uri: str + :ivar storage_account_id: The storage account id for bring your own storage scenario. + :vartype storage_account_id: str + :ivar main_template: The inline main template json which has resources to be provisioned. It + can be a JObject or well-formed JSON string. + :vartype main_template: any + :ivar create_ui_definition: The createUiDefinition json for the backing template with + Microsoft.Solutions/applications resource. It can be a JObject or well-formed JSON string. + :vartype create_ui_definition: any + :ivar notification_policy: The managed application notification policy. + :vartype notification_policy: + ~azure.mgmt.managedapplication.v2021_07_01.models.ApplicationNotificationPolicy + :ivar locking_policy: The managed application locking policy. + :vartype locking_policy: + ~azure.mgmt.managedapplication.v2021_07_01.models.ApplicationPackageLockingPolicyDefinition + :ivar deployment_policy: The managed application deployment policy. + :vartype deployment_policy: + ~azure.mgmt.managedapplication.v2021_07_01.models.ApplicationDeploymentPolicy + :ivar management_policy: The managed application management policy that determines publisher's + access to the managed resource group. + :vartype management_policy: + ~azure.mgmt.managedapplication.v2021_07_01.models.ApplicationManagementPolicy + :ivar policies: The managed application provider policies. + :vartype policies: list[~azure.mgmt.managedapplication.v2021_07_01.models.ApplicationPolicy] + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'system_data': {'readonly': True}, + 'lock_level': {'required': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'location': {'key': 'location', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + 'system_data': {'key': 'systemData', 'type': 'SystemData'}, + 'managed_by': {'key': 'managedBy', 'type': 'str'}, + 'sku': {'key': 'sku', 'type': 'Sku'}, + 'lock_level': {'key': 'properties.lockLevel', 'type': 'str'}, + 'display_name': {'key': 'properties.displayName', 'type': 'str'}, + 'is_enabled': {'key': 'properties.isEnabled', 'type': 'bool'}, + 'authorizations': {'key': 'properties.authorizations', 'type': '[ApplicationAuthorization]'}, + 'artifacts': {'key': 'properties.artifacts', 'type': '[ApplicationDefinitionArtifact]'}, + 'description': {'key': 'properties.description', 'type': 'str'}, + 'package_file_uri': {'key': 'properties.packageFileUri', 'type': 'str'}, + 'storage_account_id': {'key': 'properties.storageAccountId', 'type': 'str'}, + 'main_template': {'key': 'properties.mainTemplate', 'type': 'object'}, + 'create_ui_definition': {'key': 'properties.createUiDefinition', 'type': 'object'}, + 'notification_policy': {'key': 'properties.notificationPolicy', 'type': 'ApplicationNotificationPolicy'}, + 'locking_policy': {'key': 'properties.lockingPolicy', 'type': 'ApplicationPackageLockingPolicyDefinition'}, + 'deployment_policy': {'key': 'properties.deploymentPolicy', 'type': 'ApplicationDeploymentPolicy'}, + 'management_policy': {'key': 'properties.managementPolicy', 'type': 'ApplicationManagementPolicy'}, + 'policies': {'key': 'properties.policies', 'type': '[ApplicationPolicy]'}, + } + + def __init__( + self, + *, + lock_level: Union[str, "_models.ApplicationLockLevel"], + location: Optional[str] = None, + tags: Optional[Dict[str, str]] = None, + managed_by: Optional[str] = None, + sku: Optional["_models.Sku"] = None, + display_name: Optional[str] = None, + is_enabled: Optional[bool] = None, + authorizations: Optional[List["_models.ApplicationAuthorization"]] = None, + artifacts: Optional[List["_models.ApplicationDefinitionArtifact"]] = None, + description: Optional[str] = None, + package_file_uri: Optional[str] = None, + storage_account_id: Optional[str] = None, + main_template: Optional[Any] = None, + create_ui_definition: Optional[Any] = None, + notification_policy: Optional["_models.ApplicationNotificationPolicy"] = None, + locking_policy: Optional["_models.ApplicationPackageLockingPolicyDefinition"] = None, + deployment_policy: Optional["_models.ApplicationDeploymentPolicy"] = None, + management_policy: Optional["_models.ApplicationManagementPolicy"] = None, + policies: Optional[List["_models.ApplicationPolicy"]] = None, + **kwargs + ): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword managed_by: ID of the resource that manages this resource. + :paramtype managed_by: str + :keyword sku: The SKU of the resource. + :paramtype sku: ~azure.mgmt.managedapplication.v2021_07_01.models.Sku + :keyword lock_level: Required. The managed application lock level. Known values are: + "CanNotDelete", "ReadOnly", "None". + :paramtype lock_level: str or + ~azure.mgmt.managedapplication.v2021_07_01.models.ApplicationLockLevel + :keyword display_name: The managed application definition display name. + :paramtype display_name: str + :keyword is_enabled: A value indicating whether the package is enabled or not. + :paramtype is_enabled: bool + :keyword authorizations: The managed application provider authorizations. + :paramtype authorizations: + list[~azure.mgmt.managedapplication.v2021_07_01.models.ApplicationAuthorization] + :keyword artifacts: The collection of managed application artifacts. The portal will use the + files specified as artifacts to construct the user experience of creating a managed application + from a managed application definition. + :paramtype artifacts: + list[~azure.mgmt.managedapplication.v2021_07_01.models.ApplicationDefinitionArtifact] + :keyword description: The managed application definition description. + :paramtype description: str + :keyword package_file_uri: The managed application definition package file Uri. Use this + element. + :paramtype package_file_uri: str + :keyword storage_account_id: The storage account id for bring your own storage scenario. + :paramtype storage_account_id: str + :keyword main_template: The inline main template json which has resources to be provisioned. It + can be a JObject or well-formed JSON string. + :paramtype main_template: any + :keyword create_ui_definition: The createUiDefinition json for the backing template with + Microsoft.Solutions/applications resource. It can be a JObject or well-formed JSON string. + :paramtype create_ui_definition: any + :keyword notification_policy: The managed application notification policy. + :paramtype notification_policy: + ~azure.mgmt.managedapplication.v2021_07_01.models.ApplicationNotificationPolicy + :keyword locking_policy: The managed application locking policy. + :paramtype locking_policy: + ~azure.mgmt.managedapplication.v2021_07_01.models.ApplicationPackageLockingPolicyDefinition + :keyword deployment_policy: The managed application deployment policy. + :paramtype deployment_policy: + ~azure.mgmt.managedapplication.v2021_07_01.models.ApplicationDeploymentPolicy + :keyword management_policy: The managed application management policy that determines + publisher's access to the managed resource group. + :paramtype management_policy: + ~azure.mgmt.managedapplication.v2021_07_01.models.ApplicationManagementPolicy + :keyword policies: The managed application provider policies. + :paramtype policies: list[~azure.mgmt.managedapplication.v2021_07_01.models.ApplicationPolicy] + """ + super(ApplicationDefinition, self).__init__(location=location, tags=tags, managed_by=managed_by, sku=sku, **kwargs) + self.lock_level = lock_level + self.display_name = display_name + self.is_enabled = is_enabled + self.authorizations = authorizations + self.artifacts = artifacts + self.description = description + self.package_file_uri = package_file_uri + self.storage_account_id = storage_account_id + self.main_template = main_template + self.create_ui_definition = create_ui_definition + self.notification_policy = notification_policy + self.locking_policy = locking_policy + self.deployment_policy = deployment_policy + self.management_policy = management_policy + self.policies = policies + + +class ApplicationDefinitionArtifact(msrest.serialization.Model): + """Application definition artifact. + + All required parameters must be populated in order to send to Azure. + + :ivar name: Required. The managed application definition artifact name. Known values are: + "NotSpecified", "ApplicationResourceTemplate", "CreateUiDefinition", "MainTemplateParameters". + :vartype name: str or + ~azure.mgmt.managedapplication.v2021_07_01.models.ApplicationDefinitionArtifactName + :ivar uri: Required. The managed application definition artifact blob uri. + :vartype uri: str + :ivar type: Required. The managed application definition artifact type. Known values are: + "NotSpecified", "Template", "Custom". + :vartype type: str or ~azure.mgmt.managedapplication.v2021_07_01.models.ApplicationArtifactType + """ + + _validation = { + 'name': {'required': True}, + 'uri': {'required': True}, + 'type': {'required': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'uri': {'key': 'uri', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + } + + def __init__( + self, + *, + name: Union[str, "_models.ApplicationDefinitionArtifactName"], + uri: str, + type: Union[str, "_models.ApplicationArtifactType"], + **kwargs + ): + """ + :keyword name: Required. The managed application definition artifact name. Known values are: + "NotSpecified", "ApplicationResourceTemplate", "CreateUiDefinition", "MainTemplateParameters". + :paramtype name: str or + ~azure.mgmt.managedapplication.v2021_07_01.models.ApplicationDefinitionArtifactName + :keyword uri: Required. The managed application definition artifact blob uri. + :paramtype uri: str + :keyword type: Required. The managed application definition artifact type. Known values are: + "NotSpecified", "Template", "Custom". + :paramtype type: str or + ~azure.mgmt.managedapplication.v2021_07_01.models.ApplicationArtifactType + """ + super(ApplicationDefinitionArtifact, self).__init__(**kwargs) + self.name = name + self.uri = uri + self.type = type + + +class ApplicationDefinitionListResult(msrest.serialization.Model): + """List of managed application definitions. + + :ivar value: The array of managed application definitions. + :vartype value: list[~azure.mgmt.managedapplication.v2021_07_01.models.ApplicationDefinition] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[ApplicationDefinition]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["_models.ApplicationDefinition"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + """ + :keyword value: The array of managed application definitions. + :paramtype value: list[~azure.mgmt.managedapplication.v2021_07_01.models.ApplicationDefinition] + :keyword next_link: The URL to use for getting the next set of results. + :paramtype next_link: str + """ + super(ApplicationDefinitionListResult, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class ApplicationDefinitionPatchable(msrest.serialization.Model): + """Information about an application definition request. + + :ivar tags: A set of tags. Application definition tags. + :vartype tags: dict[str, str] + """ + + _attribute_map = { + 'tags': {'key': 'tags', 'type': '{str}'}, + } + + def __init__( + self, + *, + tags: Optional[Dict[str, str]] = None, + **kwargs + ): + """ + :keyword tags: A set of tags. Application definition tags. + :paramtype tags: dict[str, str] + """ + super(ApplicationDefinitionPatchable, self).__init__(**kwargs) + self.tags = tags + + +class ApplicationDeploymentPolicy(msrest.serialization.Model): + """Managed application deployment policy. + + All required parameters must be populated in order to send to Azure. + + :ivar deployment_mode: Required. The managed application deployment mode. Known values are: + "NotSpecified", "Incremental", "Complete". + :vartype deployment_mode: str or + ~azure.mgmt.managedapplication.v2021_07_01.models.DeploymentMode + """ + + _validation = { + 'deployment_mode': {'required': True}, + } + + _attribute_map = { + 'deployment_mode': {'key': 'deploymentMode', 'type': 'str'}, + } + + def __init__( + self, + *, + deployment_mode: Union[str, "_models.DeploymentMode"], + **kwargs + ): + """ + :keyword deployment_mode: Required. The managed application deployment mode. Known values are: + "NotSpecified", "Incremental", "Complete". + :paramtype deployment_mode: str or + ~azure.mgmt.managedapplication.v2021_07_01.models.DeploymentMode + """ + super(ApplicationDeploymentPolicy, self).__init__(**kwargs) + self.deployment_mode = deployment_mode + + +class ApplicationJitAccessPolicy(msrest.serialization.Model): + """Managed application Jit access policy. + + All required parameters must be populated in order to send to Azure. + + :ivar jit_access_enabled: Required. Whether the JIT access is enabled. + :vartype jit_access_enabled: bool + :ivar jit_approval_mode: JIT approval mode. Known values are: "NotSpecified", "AutoApprove", + "ManualApprove". + :vartype jit_approval_mode: str or + ~azure.mgmt.managedapplication.v2021_07_01.models.JitApprovalMode + :ivar jit_approvers: The JIT approvers. + :vartype jit_approvers: + list[~azure.mgmt.managedapplication.v2021_07_01.models.JitApproverDefinition] + :ivar maximum_jit_access_duration: The maximum duration JIT access is granted. This is an + ISO8601 time period value. + :vartype maximum_jit_access_duration: str + """ + + _validation = { + 'jit_access_enabled': {'required': True}, + } + + _attribute_map = { + 'jit_access_enabled': {'key': 'jitAccessEnabled', 'type': 'bool'}, + 'jit_approval_mode': {'key': 'jitApprovalMode', 'type': 'str'}, + 'jit_approvers': {'key': 'jitApprovers', 'type': '[JitApproverDefinition]'}, + 'maximum_jit_access_duration': {'key': 'maximumJitAccessDuration', 'type': 'str'}, + } + + def __init__( + self, + *, + jit_access_enabled: bool, + jit_approval_mode: Optional[Union[str, "_models.JitApprovalMode"]] = None, + jit_approvers: Optional[List["_models.JitApproverDefinition"]] = None, + maximum_jit_access_duration: Optional[str] = None, + **kwargs + ): + """ + :keyword jit_access_enabled: Required. Whether the JIT access is enabled. + :paramtype jit_access_enabled: bool + :keyword jit_approval_mode: JIT approval mode. Known values are: "NotSpecified", "AutoApprove", + "ManualApprove". + :paramtype jit_approval_mode: str or + ~azure.mgmt.managedapplication.v2021_07_01.models.JitApprovalMode + :keyword jit_approvers: The JIT approvers. + :paramtype jit_approvers: + list[~azure.mgmt.managedapplication.v2021_07_01.models.JitApproverDefinition] + :keyword maximum_jit_access_duration: The maximum duration JIT access is granted. This is an + ISO8601 time period value. + :paramtype maximum_jit_access_duration: str + """ + super(ApplicationJitAccessPolicy, self).__init__(**kwargs) + self.jit_access_enabled = jit_access_enabled + self.jit_approval_mode = jit_approval_mode + self.jit_approvers = jit_approvers + self.maximum_jit_access_duration = maximum_jit_access_duration + + +class ApplicationListResult(msrest.serialization.Model): + """List of managed applications. + + :ivar value: The array of managed applications. + :vartype value: list[~azure.mgmt.managedapplication.v2021_07_01.models.Application] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Application]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["_models.Application"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + """ + :keyword value: The array of managed applications. + :paramtype value: list[~azure.mgmt.managedapplication.v2021_07_01.models.Application] + :keyword next_link: The URL to use for getting the next set of results. + :paramtype next_link: str + """ + super(ApplicationListResult, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class ApplicationManagementPolicy(msrest.serialization.Model): + """Managed application management policy. + + :ivar mode: The managed application management mode. Known values are: "NotSpecified", + "Unmanaged", "Managed". + :vartype mode: str or + ~azure.mgmt.managedapplication.v2021_07_01.models.ApplicationManagementMode + """ + + _attribute_map = { + 'mode': {'key': 'mode', 'type': 'str'}, + } + + def __init__( + self, + *, + mode: Optional[Union[str, "_models.ApplicationManagementMode"]] = None, + **kwargs + ): + """ + :keyword mode: The managed application management mode. Known values are: "NotSpecified", + "Unmanaged", "Managed". + :paramtype mode: str or + ~azure.mgmt.managedapplication.v2021_07_01.models.ApplicationManagementMode + """ + super(ApplicationManagementPolicy, self).__init__(**kwargs) + self.mode = mode + + +class ApplicationNotificationEndpoint(msrest.serialization.Model): + """Managed application notification endpoint. + + All required parameters must be populated in order to send to Azure. + + :ivar uri: Required. The managed application notification endpoint uri. + :vartype uri: str + """ + + _validation = { + 'uri': {'required': True}, + } + + _attribute_map = { + 'uri': {'key': 'uri', 'type': 'str'}, + } + + def __init__( + self, + *, + uri: str, + **kwargs + ): + """ + :keyword uri: Required. The managed application notification endpoint uri. + :paramtype uri: str + """ + super(ApplicationNotificationEndpoint, self).__init__(**kwargs) + self.uri = uri + + +class ApplicationNotificationPolicy(msrest.serialization.Model): + """Managed application notification policy. + + All required parameters must be populated in order to send to Azure. + + :ivar notification_endpoints: Required. The managed application notification endpoint. + :vartype notification_endpoints: + list[~azure.mgmt.managedapplication.v2021_07_01.models.ApplicationNotificationEndpoint] + """ + + _validation = { + 'notification_endpoints': {'required': True}, + } + + _attribute_map = { + 'notification_endpoints': {'key': 'notificationEndpoints', 'type': '[ApplicationNotificationEndpoint]'}, + } + + def __init__( + self, + *, + notification_endpoints: List["_models.ApplicationNotificationEndpoint"], + **kwargs + ): + """ + :keyword notification_endpoints: Required. The managed application notification endpoint. + :paramtype notification_endpoints: + list[~azure.mgmt.managedapplication.v2021_07_01.models.ApplicationNotificationEndpoint] + """ + super(ApplicationNotificationPolicy, self).__init__(**kwargs) + self.notification_endpoints = notification_endpoints + + +class ApplicationPackageContact(msrest.serialization.Model): + """The application package contact information. + + All required parameters must be populated in order to send to Azure. + + :ivar contact_name: The contact name. + :vartype contact_name: str + :ivar email: Required. The contact email. + :vartype email: str + :ivar phone: Required. The contact phone number. + :vartype phone: str + """ + + _validation = { + 'email': {'required': True}, + 'phone': {'required': True}, + } + + _attribute_map = { + 'contact_name': {'key': 'contactName', 'type': 'str'}, + 'email': {'key': 'email', 'type': 'str'}, + 'phone': {'key': 'phone', 'type': 'str'}, + } + + def __init__( + self, + *, + email: str, + phone: str, + contact_name: Optional[str] = None, + **kwargs + ): + """ + :keyword contact_name: The contact name. + :paramtype contact_name: str + :keyword email: Required. The contact email. + :paramtype email: str + :keyword phone: Required. The contact phone number. + :paramtype phone: str + """ + super(ApplicationPackageContact, self).__init__(**kwargs) + self.contact_name = contact_name + self.email = email + self.phone = phone + + +class ApplicationPackageLockingPolicyDefinition(msrest.serialization.Model): + """Managed application locking policy. + + :ivar allowed_actions: The deny assignment excluded actions. + :vartype allowed_actions: list[str] + :ivar allowed_data_actions: The deny assignment excluded data actions. + :vartype allowed_data_actions: list[str] + """ + + _attribute_map = { + 'allowed_actions': {'key': 'allowedActions', 'type': '[str]'}, + 'allowed_data_actions': {'key': 'allowedDataActions', 'type': '[str]'}, + } + + def __init__( + self, + *, + allowed_actions: Optional[List[str]] = None, + allowed_data_actions: Optional[List[str]] = None, + **kwargs + ): + """ + :keyword allowed_actions: The deny assignment excluded actions. + :paramtype allowed_actions: list[str] + :keyword allowed_data_actions: The deny assignment excluded data actions. + :paramtype allowed_data_actions: list[str] + """ + super(ApplicationPackageLockingPolicyDefinition, self).__init__(**kwargs) + self.allowed_actions = allowed_actions + self.allowed_data_actions = allowed_data_actions + + +class ApplicationPackageSupportUrls(msrest.serialization.Model): + """The appliance package support URLs. + + :ivar public_azure: The public azure support URL. + :vartype public_azure: str + :ivar government_cloud: The government cloud support URL. + :vartype government_cloud: str + """ + + _attribute_map = { + 'public_azure': {'key': 'publicAzure', 'type': 'str'}, + 'government_cloud': {'key': 'governmentCloud', 'type': 'str'}, + } + + def __init__( + self, + *, + public_azure: Optional[str] = None, + government_cloud: Optional[str] = None, + **kwargs + ): + """ + :keyword public_azure: The public azure support URL. + :paramtype public_azure: str + :keyword government_cloud: The government cloud support URL. + :paramtype government_cloud: str + """ + super(ApplicationPackageSupportUrls, self).__init__(**kwargs) + self.public_azure = public_azure + self.government_cloud = government_cloud + + +class ApplicationPatchable(GenericResource): + """Information about managed application. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Resource ID. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar location: Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~azure.mgmt.managedapplication.v2021_07_01.models.SystemData + :ivar managed_by: ID of the resource that manages this resource. + :vartype managed_by: str + :ivar sku: The SKU of the resource. + :vartype sku: ~azure.mgmt.managedapplication.v2021_07_01.models.Sku + :ivar plan: The plan information. + :vartype plan: ~azure.mgmt.managedapplication.v2021_07_01.models.PlanPatchable + :ivar kind: The kind of the managed application. Allowed values are MarketPlace and + ServiceCatalog. + :vartype kind: str + :ivar identity: The identity of the resource. + :vartype identity: ~azure.mgmt.managedapplication.v2021_07_01.models.Identity + :ivar managed_resource_group_id: The managed resource group Id. + :vartype managed_resource_group_id: str + :ivar application_definition_id: The fully qualified path of managed application definition Id. + :vartype application_definition_id: str + :ivar parameters: Name and value pairs that define the managed application parameters. It can + be a JObject or a well formed JSON string. + :vartype parameters: any + :ivar outputs: Name and value pairs that define the managed application outputs. + :vartype outputs: any + :ivar provisioning_state: The managed application provisioning state. Known values are: + "NotSpecified", "Accepted", "Running", "Deleting", "Deleted", "Canceled", "Failed", + "Succeeded", "Updating". + :vartype provisioning_state: str or + ~azure.mgmt.managedapplication.v2021_07_01.models.ProvisioningState + :ivar billing_details: The managed application billing details. + :vartype billing_details: + ~azure.mgmt.managedapplication.v2021_07_01.models.ApplicationBillingDetailsDefinition + :ivar jit_access_policy: The managed application Jit access policy. + :vartype jit_access_policy: + ~azure.mgmt.managedapplication.v2021_07_01.models.ApplicationJitAccessPolicy + :ivar publisher_tenant_id: The publisher tenant Id. + :vartype publisher_tenant_id: str + :ivar authorizations: The read-only authorizations property that is retrieved from the + application package. + :vartype authorizations: + list[~azure.mgmt.managedapplication.v2021_07_01.models.ApplicationAuthorization] + :ivar management_mode: The managed application management mode. Known values are: + "NotSpecified", "Unmanaged", "Managed". + :vartype management_mode: str or + ~azure.mgmt.managedapplication.v2021_07_01.models.ApplicationManagementMode + :ivar customer_support: The read-only customer support property that is retrieved from the + application package. + :vartype customer_support: + ~azure.mgmt.managedapplication.v2021_07_01.models.ApplicationPackageContact + :ivar support_urls: The read-only support URLs property that is retrieved from the application + package. + :vartype support_urls: + ~azure.mgmt.managedapplication.v2021_07_01.models.ApplicationPackageSupportUrls + :ivar artifacts: The collection of managed application artifacts. + :vartype artifacts: list[~azure.mgmt.managedapplication.v2021_07_01.models.ApplicationArtifact] + :ivar created_by: The client entity that created the JIT request. + :vartype created_by: ~azure.mgmt.managedapplication.v2021_07_01.models.ApplicationClientDetails + :ivar updated_by: The client entity that last updated the JIT request. + :vartype updated_by: ~azure.mgmt.managedapplication.v2021_07_01.models.ApplicationClientDetails + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'system_data': {'readonly': True}, + 'kind': {'pattern': r'^[-\w\._,\(\)]+$'}, + 'outputs': {'readonly': True}, + 'provisioning_state': {'readonly': True}, + 'billing_details': {'readonly': True}, + 'publisher_tenant_id': {'readonly': True}, + 'authorizations': {'readonly': True}, + 'management_mode': {'readonly': True}, + 'customer_support': {'readonly': True}, + 'support_urls': {'readonly': True}, + 'artifacts': {'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'}, + 'location': {'key': 'location', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + 'system_data': {'key': 'systemData', 'type': 'SystemData'}, + 'managed_by': {'key': 'managedBy', 'type': 'str'}, + 'sku': {'key': 'sku', 'type': 'Sku'}, + 'plan': {'key': 'plan', 'type': 'PlanPatchable'}, + 'kind': {'key': 'kind', 'type': 'str'}, + 'identity': {'key': 'identity', 'type': 'Identity'}, + 'managed_resource_group_id': {'key': 'properties.managedResourceGroupId', 'type': 'str'}, + 'application_definition_id': {'key': 'properties.applicationDefinitionId', 'type': 'str'}, + 'parameters': {'key': 'properties.parameters', 'type': 'object'}, + 'outputs': {'key': 'properties.outputs', 'type': 'object'}, + 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + 'billing_details': {'key': 'properties.billingDetails', 'type': 'ApplicationBillingDetailsDefinition'}, + 'jit_access_policy': {'key': 'properties.jitAccessPolicy', 'type': 'ApplicationJitAccessPolicy'}, + 'publisher_tenant_id': {'key': 'properties.publisherTenantId', 'type': 'str'}, + 'authorizations': {'key': 'properties.authorizations', 'type': '[ApplicationAuthorization]'}, + 'management_mode': {'key': 'properties.managementMode', 'type': 'str'}, + 'customer_support': {'key': 'properties.customerSupport', 'type': 'ApplicationPackageContact'}, + 'support_urls': {'key': 'properties.supportUrls', 'type': 'ApplicationPackageSupportUrls'}, + 'artifacts': {'key': 'properties.artifacts', 'type': '[ApplicationArtifact]'}, + 'created_by': {'key': 'properties.createdBy', 'type': 'ApplicationClientDetails'}, + 'updated_by': {'key': 'properties.updatedBy', 'type': 'ApplicationClientDetails'}, + } + + def __init__( + self, + *, + location: Optional[str] = None, + tags: Optional[Dict[str, str]] = None, + managed_by: Optional[str] = None, + sku: Optional["_models.Sku"] = None, + plan: Optional["_models.PlanPatchable"] = None, + kind: Optional[str] = None, + identity: Optional["_models.Identity"] = None, + managed_resource_group_id: Optional[str] = None, + application_definition_id: Optional[str] = None, + parameters: Optional[Any] = None, + jit_access_policy: Optional["_models.ApplicationJitAccessPolicy"] = None, + **kwargs + ): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword managed_by: ID of the resource that manages this resource. + :paramtype managed_by: str + :keyword sku: The SKU of the resource. + :paramtype sku: ~azure.mgmt.managedapplication.v2021_07_01.models.Sku + :keyword plan: The plan information. + :paramtype plan: ~azure.mgmt.managedapplication.v2021_07_01.models.PlanPatchable + :keyword kind: The kind of the managed application. Allowed values are MarketPlace and + ServiceCatalog. + :paramtype kind: str + :keyword identity: The identity of the resource. + :paramtype identity: ~azure.mgmt.managedapplication.v2021_07_01.models.Identity + :keyword managed_resource_group_id: The managed resource group Id. + :paramtype managed_resource_group_id: str + :keyword application_definition_id: The fully qualified path of managed application definition + Id. + :paramtype application_definition_id: str + :keyword parameters: Name and value pairs that define the managed application parameters. It + can be a JObject or a well formed JSON string. + :paramtype parameters: any + :keyword jit_access_policy: The managed application Jit access policy. + :paramtype jit_access_policy: + ~azure.mgmt.managedapplication.v2021_07_01.models.ApplicationJitAccessPolicy + """ + super(ApplicationPatchable, self).__init__(location=location, tags=tags, managed_by=managed_by, sku=sku, **kwargs) + self.plan = plan + self.kind = kind + self.identity = identity + self.managed_resource_group_id = managed_resource_group_id + self.application_definition_id = application_definition_id + self.parameters = parameters + self.outputs = None + self.provisioning_state = None + self.billing_details = None + self.jit_access_policy = jit_access_policy + self.publisher_tenant_id = None + self.authorizations = None + self.management_mode = None + self.customer_support = None + self.support_urls = None + self.artifacts = None + self.created_by = None + self.updated_by = None + + +class ApplicationPolicy(msrest.serialization.Model): + """Managed application policy. + + :ivar name: The policy name. + :vartype name: str + :ivar policy_definition_id: The policy definition Id. + :vartype policy_definition_id: str + :ivar parameters: The policy parameters. + :vartype parameters: str + """ + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'policy_definition_id': {'key': 'policyDefinitionId', 'type': 'str'}, + 'parameters': {'key': 'parameters', 'type': 'str'}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + policy_definition_id: Optional[str] = None, + parameters: Optional[str] = None, + **kwargs + ): + """ + :keyword name: The policy name. + :paramtype name: str + :keyword policy_definition_id: The policy definition Id. + :paramtype policy_definition_id: str + :keyword parameters: The policy parameters. + :paramtype parameters: str + """ + super(ApplicationPolicy, self).__init__(**kwargs) + self.name = name + self.policy_definition_id = policy_definition_id + self.parameters = parameters + + +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.managedapplication.v2021_07_01.models.ErrorDetail] + :ivar additional_info: The error additional info. + :vartype additional_info: + list[~azure.mgmt.managedapplication.v2021_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.). + + :ivar error: The error object. + :vartype error: ~azure.mgmt.managedapplication.v2021_07_01.models.ErrorDetail + """ + + _attribute_map = { + 'error': {'key': 'error', 'type': 'ErrorDetail'}, + } + + def __init__( + self, + *, + error: Optional["_models.ErrorDetail"] = None, + **kwargs + ): + """ + :keyword error: The error object. + :paramtype error: ~azure.mgmt.managedapplication.v2021_07_01.models.ErrorDetail + """ + super(ErrorResponse, self).__init__(**kwargs) + self.error = error + + +class Identity(msrest.serialization.Model): + """Identity for the resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar principal_id: The principal ID of resource identity. + :vartype principal_id: str + :ivar tenant_id: The tenant ID of resource. + :vartype tenant_id: str + :ivar type: The identity type. Known values are: "SystemAssigned", "UserAssigned", + "SystemAssigned, UserAssigned", "None". + :vartype type: str or ~azure.mgmt.managedapplication.v2021_07_01.models.ResourceIdentityType + :ivar user_assigned_identities: The list of user identities associated with the resource. The + user identity dictionary key references will be resource ids in the form: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'. + :vartype user_assigned_identities: dict[str, + ~azure.mgmt.managedapplication.v2021_07_01.models.UserAssignedResourceIdentity] + """ + + _validation = { + 'principal_id': {'readonly': True}, + 'tenant_id': {'readonly': True}, + } + + _attribute_map = { + 'principal_id': {'key': 'principalId', 'type': 'str'}, + 'tenant_id': {'key': 'tenantId', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'user_assigned_identities': {'key': 'userAssignedIdentities', 'type': '{UserAssignedResourceIdentity}'}, + } + + def __init__( + self, + *, + type: Optional[Union[str, "_models.ResourceIdentityType"]] = None, + user_assigned_identities: Optional[Dict[str, "_models.UserAssignedResourceIdentity"]] = None, + **kwargs + ): + """ + :keyword type: The identity type. Known values are: "SystemAssigned", "UserAssigned", + "SystemAssigned, UserAssigned", "None". + :paramtype type: str or ~azure.mgmt.managedapplication.v2021_07_01.models.ResourceIdentityType + :keyword user_assigned_identities: The list of user identities associated with the resource. + The user identity dictionary key references will be resource ids in the form: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'. + :paramtype user_assigned_identities: dict[str, + ~azure.mgmt.managedapplication.v2021_07_01.models.UserAssignedResourceIdentity] + """ + super(Identity, self).__init__(**kwargs) + self.principal_id = None + self.tenant_id = None + self.type = type + self.user_assigned_identities = user_assigned_identities + + +class JitApproverDefinition(msrest.serialization.Model): + """JIT approver definition. + + All required parameters must be populated in order to send to Azure. + + :ivar id: Required. The approver service principal Id. + :vartype id: str + :ivar type: The approver type. Known values are: "user", "group". + :vartype type: str or ~azure.mgmt.managedapplication.v2021_07_01.models.JitApproverType + :ivar display_name: The approver display name. + :vartype display_name: str + """ + + _validation = { + 'id': {'required': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'display_name': {'key': 'displayName', 'type': 'str'}, + } + + def __init__( + self, + *, + id: str, + type: Optional[Union[str, "_models.JitApproverType"]] = None, + display_name: Optional[str] = None, + **kwargs + ): + """ + :keyword id: Required. The approver service principal Id. + :paramtype id: str + :keyword type: The approver type. Known values are: "user", "group". + :paramtype type: str or ~azure.mgmt.managedapplication.v2021_07_01.models.JitApproverType + :keyword display_name: The approver display name. + :paramtype display_name: str + """ + super(JitApproverDefinition, self).__init__(**kwargs) + self.id = id + self.type = type + self.display_name = display_name + + +class JitAuthorizationPolicies(msrest.serialization.Model): + """The JIT authorization policies. + + All required parameters must be populated in order to send to Azure. + + :ivar principal_id: Required. The the principal id that will be granted JIT access. + :vartype principal_id: str + :ivar role_definition_id: Required. The role definition id that will be granted to the + Principal. + :vartype role_definition_id: str + """ + + _validation = { + 'principal_id': {'required': True}, + 'role_definition_id': {'required': True}, + } + + _attribute_map = { + 'principal_id': {'key': 'principalId', 'type': 'str'}, + 'role_definition_id': {'key': 'roleDefinitionId', 'type': 'str'}, + } + + def __init__( + self, + *, + principal_id: str, + role_definition_id: str, + **kwargs + ): + """ + :keyword principal_id: Required. The the principal id that will be granted JIT access. + :paramtype principal_id: str + :keyword role_definition_id: Required. The role definition id that will be granted to the + Principal. + :paramtype role_definition_id: str + """ + super(JitAuthorizationPolicies, self).__init__(**kwargs) + self.principal_id = principal_id + self.role_definition_id = role_definition_id + + +class JitRequestDefinition(Resource): + """Information about JIT request definition. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Resource ID. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar location: Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~azure.mgmt.managedapplication.v2021_07_01.models.SystemData + :ivar application_resource_id: The parent application id. + :vartype application_resource_id: str + :ivar publisher_tenant_id: The publisher tenant id. + :vartype publisher_tenant_id: str + :ivar jit_authorization_policies: The JIT authorization policies. + :vartype jit_authorization_policies: + list[~azure.mgmt.managedapplication.v2021_07_01.models.JitAuthorizationPolicies] + :ivar jit_scheduling_policy: The JIT request properties. + :vartype jit_scheduling_policy: + ~azure.mgmt.managedapplication.v2021_07_01.models.JitSchedulingPolicy + :ivar provisioning_state: The JIT request provisioning state. Known values are: "NotSpecified", + "Accepted", "Running", "Deleting", "Deleted", "Canceled", "Failed", "Succeeded", "Updating". + :vartype provisioning_state: str or + ~azure.mgmt.managedapplication.v2021_07_01.models.ProvisioningState + :ivar jit_request_state: The JIT request state. Known values are: "NotSpecified", "Pending", + "Approved", "Denied", "Failed", "Canceled", "Expired", "Timeout". + :vartype jit_request_state: str or + ~azure.mgmt.managedapplication.v2021_07_01.models.JitRequestState + :ivar created_by: The client entity that created the JIT request. + :vartype created_by: ~azure.mgmt.managedapplication.v2021_07_01.models.ApplicationClientDetails + :ivar updated_by: The client entity that last updated the JIT request. + :vartype updated_by: ~azure.mgmt.managedapplication.v2021_07_01.models.ApplicationClientDetails + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'system_data': {'readonly': True}, + 'publisher_tenant_id': {'readonly': True}, + 'provisioning_state': {'readonly': True}, + 'jit_request_state': {'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'}, + 'location': {'key': 'location', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + 'system_data': {'key': 'systemData', 'type': 'SystemData'}, + 'application_resource_id': {'key': 'properties.applicationResourceId', 'type': 'str'}, + 'publisher_tenant_id': {'key': 'properties.publisherTenantId', 'type': 'str'}, + 'jit_authorization_policies': {'key': 'properties.jitAuthorizationPolicies', 'type': '[JitAuthorizationPolicies]'}, + 'jit_scheduling_policy': {'key': 'properties.jitSchedulingPolicy', 'type': 'JitSchedulingPolicy'}, + 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + 'jit_request_state': {'key': 'properties.jitRequestState', 'type': 'str'}, + 'created_by': {'key': 'properties.createdBy', 'type': 'ApplicationClientDetails'}, + 'updated_by': {'key': 'properties.updatedBy', 'type': 'ApplicationClientDetails'}, + } + + def __init__( + self, + *, + location: Optional[str] = None, + tags: Optional[Dict[str, str]] = None, + application_resource_id: Optional[str] = None, + jit_authorization_policies: Optional[List["_models.JitAuthorizationPolicies"]] = None, + jit_scheduling_policy: Optional["_models.JitSchedulingPolicy"] = None, + **kwargs + ): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword application_resource_id: The parent application id. + :paramtype application_resource_id: str + :keyword jit_authorization_policies: The JIT authorization policies. + :paramtype jit_authorization_policies: + list[~azure.mgmt.managedapplication.v2021_07_01.models.JitAuthorizationPolicies] + :keyword jit_scheduling_policy: The JIT request properties. + :paramtype jit_scheduling_policy: + ~azure.mgmt.managedapplication.v2021_07_01.models.JitSchedulingPolicy + """ + super(JitRequestDefinition, self).__init__(location=location, tags=tags, **kwargs) + self.application_resource_id = application_resource_id + self.publisher_tenant_id = None + self.jit_authorization_policies = jit_authorization_policies + self.jit_scheduling_policy = jit_scheduling_policy + self.provisioning_state = None + self.jit_request_state = None + self.created_by = None + self.updated_by = None + + +class JitRequestDefinitionListResult(msrest.serialization.Model): + """List of JIT requests. + + :ivar value: The array of Jit request definition. + :vartype value: list[~azure.mgmt.managedapplication.v2021_07_01.models.JitRequestDefinition] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[JitRequestDefinition]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["_models.JitRequestDefinition"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + """ + :keyword value: The array of Jit request definition. + :paramtype value: list[~azure.mgmt.managedapplication.v2021_07_01.models.JitRequestDefinition] + :keyword next_link: The URL to use for getting the next set of results. + :paramtype next_link: str + """ + super(JitRequestDefinitionListResult, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class JitRequestMetadata(msrest.serialization.Model): + """The JIT request metadata. + + :ivar origin_request_id: The origin request id. + :vartype origin_request_id: str + :ivar requestor_id: The requestor id. + :vartype requestor_id: str + :ivar tenant_display_name: The publisher's tenant name. + :vartype tenant_display_name: str + :ivar subject_display_name: The subject display name. + :vartype subject_display_name: str + """ + + _attribute_map = { + 'origin_request_id': {'key': 'originRequestId', 'type': 'str'}, + 'requestor_id': {'key': 'requestorId', 'type': 'str'}, + 'tenant_display_name': {'key': 'tenantDisplayName', 'type': 'str'}, + 'subject_display_name': {'key': 'subjectDisplayName', 'type': 'str'}, + } + + def __init__( + self, + *, + origin_request_id: Optional[str] = None, + requestor_id: Optional[str] = None, + tenant_display_name: Optional[str] = None, + subject_display_name: Optional[str] = None, + **kwargs + ): + """ + :keyword origin_request_id: The origin request id. + :paramtype origin_request_id: str + :keyword requestor_id: The requestor id. + :paramtype requestor_id: str + :keyword tenant_display_name: The publisher's tenant name. + :paramtype tenant_display_name: str + :keyword subject_display_name: The subject display name. + :paramtype subject_display_name: str + """ + super(JitRequestMetadata, self).__init__(**kwargs) + self.origin_request_id = origin_request_id + self.requestor_id = requestor_id + self.tenant_display_name = tenant_display_name + self.subject_display_name = subject_display_name + + +class JitRequestPatchable(msrest.serialization.Model): + """Information about JIT request. + + :ivar tags: A set of tags. Jit request tags. + :vartype tags: dict[str, str] + """ + + _attribute_map = { + 'tags': {'key': 'tags', 'type': '{str}'}, + } + + def __init__( + self, + *, + tags: Optional[Dict[str, str]] = None, + **kwargs + ): + """ + :keyword tags: A set of tags. Jit request tags. + :paramtype tags: dict[str, str] + """ + super(JitRequestPatchable, self).__init__(**kwargs) + self.tags = tags + + +class JitSchedulingPolicy(msrest.serialization.Model): + """The JIT scheduling policies. + + All required parameters must be populated in order to send to Azure. + + :ivar type: Required. The type of JIT schedule. Known values are: "NotSpecified", "Once", + "Recurring". + :vartype type: str or ~azure.mgmt.managedapplication.v2021_07_01.models.JitSchedulingType + :ivar duration: Required. The required duration of the JIT request. + :vartype duration: ~datetime.timedelta + :ivar start_time: Required. The start time of the request. + :vartype start_time: ~datetime.datetime + """ + + _validation = { + 'type': {'required': True}, + 'duration': {'required': True}, + 'start_time': {'required': True}, + } + + _attribute_map = { + 'type': {'key': 'type', 'type': 'str'}, + 'duration': {'key': 'duration', 'type': 'duration'}, + 'start_time': {'key': 'startTime', 'type': 'iso-8601'}, + } + + def __init__( + self, + *, + type: Union[str, "_models.JitSchedulingType"], + duration: datetime.timedelta, + start_time: datetime.datetime, + **kwargs + ): + """ + :keyword type: Required. The type of JIT schedule. Known values are: "NotSpecified", "Once", + "Recurring". + :paramtype type: str or ~azure.mgmt.managedapplication.v2021_07_01.models.JitSchedulingType + :keyword duration: Required. The required duration of the JIT request. + :paramtype duration: ~datetime.timedelta + :keyword start_time: Required. The start time of the request. + :paramtype start_time: ~datetime.datetime + """ + super(JitSchedulingPolicy, self).__init__(**kwargs) + self.type = type + self.duration = duration + self.start_time = start_time + + +class ListTokenRequest(msrest.serialization.Model): + """List token request body. + + :ivar authorization_audience: The authorization audience. + :vartype authorization_audience: str + :ivar user_assigned_identities: The user assigned identities. + :vartype user_assigned_identities: list[str] + """ + + _attribute_map = { + 'authorization_audience': {'key': 'authorizationAudience', 'type': 'str'}, + 'user_assigned_identities': {'key': 'userAssignedIdentities', 'type': '[str]'}, + } + + def __init__( + self, + *, + authorization_audience: Optional[str] = None, + user_assigned_identities: Optional[List[str]] = None, + **kwargs + ): + """ + :keyword authorization_audience: The authorization audience. + :paramtype authorization_audience: str + :keyword user_assigned_identities: The user assigned identities. + :paramtype user_assigned_identities: list[str] + """ + super(ListTokenRequest, self).__init__(**kwargs) + self.authorization_audience = authorization_audience + self.user_assigned_identities = user_assigned_identities + + +class ManagedIdentityToken(msrest.serialization.Model): + """The managed identity token for the managed app resource. + + :ivar access_token: The requested access token. + :vartype access_token: str + :ivar expires_in: The number of seconds the access token will be valid. + :vartype expires_in: str + :ivar expires_on: The timespan when the access token expires. This is represented as the number + of seconds from epoch. + :vartype expires_on: str + :ivar not_before: The timespan when the access token takes effect. This is represented as the + number of seconds from epoch. + :vartype not_before: str + :ivar authorization_audience: The aud (audience) the access token was request for. This is the + same as what was provided in the listTokens request. + :vartype authorization_audience: str + :ivar resource_id: The Azure resource ID for the issued token. This is either the managed + application ID or the user-assigned identity ID. + :vartype resource_id: str + :ivar token_type: The type of the token. + :vartype token_type: str + """ + + _attribute_map = { + 'access_token': {'key': 'accessToken', 'type': 'str'}, + 'expires_in': {'key': 'expiresIn', 'type': 'str'}, + 'expires_on': {'key': 'expiresOn', 'type': 'str'}, + 'not_before': {'key': 'notBefore', 'type': 'str'}, + 'authorization_audience': {'key': 'authorizationAudience', 'type': 'str'}, + 'resource_id': {'key': 'resourceId', 'type': 'str'}, + 'token_type': {'key': 'tokenType', 'type': 'str'}, + } + + def __init__( + self, + *, + access_token: Optional[str] = None, + expires_in: Optional[str] = None, + expires_on: Optional[str] = None, + not_before: Optional[str] = None, + authorization_audience: Optional[str] = None, + resource_id: Optional[str] = None, + token_type: Optional[str] = None, + **kwargs + ): + """ + :keyword access_token: The requested access token. + :paramtype access_token: str + :keyword expires_in: The number of seconds the access token will be valid. + :paramtype expires_in: str + :keyword expires_on: The timespan when the access token expires. This is represented as the + number of seconds from epoch. + :paramtype expires_on: str + :keyword not_before: The timespan when the access token takes effect. This is represented as + the number of seconds from epoch. + :paramtype not_before: str + :keyword authorization_audience: The aud (audience) the access token was request for. This is + the same as what was provided in the listTokens request. + :paramtype authorization_audience: str + :keyword resource_id: The Azure resource ID for the issued token. This is either the managed + application ID or the user-assigned identity ID. + :paramtype resource_id: str + :keyword token_type: The type of the token. + :paramtype token_type: str + """ + super(ManagedIdentityToken, self).__init__(**kwargs) + self.access_token = access_token + self.expires_in = expires_in + self.expires_on = expires_on + self.not_before = not_before + self.authorization_audience = authorization_audience + self.resource_id = resource_id + self.token_type = token_type + + +class ManagedIdentityTokenResult(msrest.serialization.Model): + """The array of managed identity tokens. + + :ivar value: The array of managed identity tokens. + :vartype value: list[~azure.mgmt.managedapplication.v2021_07_01.models.ManagedIdentityToken] + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[ManagedIdentityToken]'}, + } + + def __init__( + self, + *, + value: Optional[List["_models.ManagedIdentityToken"]] = None, + **kwargs + ): + """ + :keyword value: The array of managed identity tokens. + :paramtype value: list[~azure.mgmt.managedapplication.v2021_07_01.models.ManagedIdentityToken] + """ + super(ManagedIdentityTokenResult, self).__init__(**kwargs) + self.value = value + + +class Operation(msrest.serialization.Model): + """Details of a REST API operation, returned from the Resource Provider Operations API. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name: The name of the operation, as per Resource-Based Access Control (RBAC). Examples: + "Microsoft.Compute/virtualMachines/write", "Microsoft.Compute/virtualMachines/capture/action". + :vartype name: str + :ivar is_data_action: Whether the operation applies to data-plane. This is "true" for + data-plane operations and "false" for ARM/control-plane operations. + :vartype is_data_action: bool + :ivar display: Localized display information for this particular operation. + :vartype display: ~azure.mgmt.managedapplication.v2021_07_01.models.OperationDisplay + :ivar origin: The intended executor of the operation; as in Resource Based Access Control + (RBAC) and audit logs UX. Default value is "user,system". Known values are: "user", "system", + "user,system". + :vartype origin: str or ~azure.mgmt.managedapplication.v2021_07_01.models.Origin + :ivar action_type: Enum. Indicates the action type. "Internal" refers to actions that are for + internal only APIs. Known values are: "Internal". + :vartype action_type: str or ~azure.mgmt.managedapplication.v2021_07_01.models.ActionType + """ + + _validation = { + 'name': {'readonly': True}, + 'is_data_action': {'readonly': True}, + 'origin': {'readonly': True}, + 'action_type': {'readonly': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'is_data_action': {'key': 'isDataAction', 'type': 'bool'}, + 'display': {'key': 'display', 'type': 'OperationDisplay'}, + 'origin': {'key': 'origin', 'type': 'str'}, + 'action_type': {'key': 'actionType', 'type': 'str'}, + } + + def __init__( + self, + *, + display: Optional["_models.OperationDisplay"] = None, + **kwargs + ): + """ + :keyword display: Localized display information for this particular operation. + :paramtype display: ~azure.mgmt.managedapplication.v2021_07_01.models.OperationDisplay + """ + super(Operation, self).__init__(**kwargs) + self.name = None + self.is_data_action = None + self.display = display + self.origin = None + self.action_type = None + + +class OperationDisplay(msrest.serialization.Model): + """Localized display information for this particular operation. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar provider: The localized friendly form of the resource provider name, e.g. "Microsoft + Monitoring Insights" or "Microsoft Compute". + :vartype provider: str + :ivar resource: The localized friendly name of the resource type related to this operation. + E.g. "Virtual Machines" or "Job Schedule Collections". + :vartype resource: str + :ivar operation: The concise, localized friendly name for the operation; suitable for + dropdowns. E.g. "Create or Update Virtual Machine", "Restart Virtual Machine". + :vartype operation: str + :ivar description: The short, localized friendly description of the operation; suitable for + tool tips and detailed views. + :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): + """A list of REST API operations supported by an Azure Resource Provider. It contains an URL link to get the next set of results. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: List of operations supported by the resource provider. + :vartype value: list[~azure.mgmt.managedapplication.v2021_07_01.models.Operation] + :ivar next_link: URL to get the next set of operation list results (if there are any). + :vartype next_link: str + """ + + _validation = { + 'value': {'readonly': True}, + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Operation]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(OperationListResult, self).__init__(**kwargs) + self.value = None + self.next_link = None + + +class Plan(msrest.serialization.Model): + """Plan for the managed application. + + All required parameters must be populated in order to send to Azure. + + :ivar name: Required. The plan name. + :vartype name: str + :ivar publisher: Required. The publisher ID. + :vartype publisher: str + :ivar product: Required. The product code. + :vartype product: str + :ivar promotion_code: The promotion code. + :vartype promotion_code: str + :ivar version: Required. The plan's version. + :vartype version: str + """ + + _validation = { + 'name': {'required': True}, + 'publisher': {'required': True}, + 'product': {'required': True}, + 'version': {'required': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'publisher': {'key': 'publisher', 'type': 'str'}, + 'product': {'key': 'product', 'type': 'str'}, + 'promotion_code': {'key': 'promotionCode', 'type': 'str'}, + 'version': {'key': 'version', 'type': 'str'}, + } + + def __init__( + self, + *, + name: str, + publisher: str, + product: str, + version: str, + promotion_code: Optional[str] = None, + **kwargs + ): + """ + :keyword name: Required. The plan name. + :paramtype name: str + :keyword publisher: Required. The publisher ID. + :paramtype publisher: str + :keyword product: Required. The product code. + :paramtype product: str + :keyword promotion_code: The promotion code. + :paramtype promotion_code: str + :keyword version: Required. The plan's version. + :paramtype version: str + """ + super(Plan, self).__init__(**kwargs) + self.name = name + self.publisher = publisher + self.product = product + self.promotion_code = promotion_code + self.version = version + + +class PlanPatchable(msrest.serialization.Model): + """Plan for the managed application. + + :ivar name: The plan name. + :vartype name: str + :ivar publisher: The publisher ID. + :vartype publisher: str + :ivar product: The product code. + :vartype product: str + :ivar promotion_code: The promotion code. + :vartype promotion_code: str + :ivar version: The plan's version. + :vartype version: str + """ + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'publisher': {'key': 'publisher', 'type': 'str'}, + 'product': {'key': 'product', 'type': 'str'}, + 'promotion_code': {'key': 'promotionCode', 'type': 'str'}, + 'version': {'key': 'version', 'type': 'str'}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + publisher: Optional[str] = None, + product: Optional[str] = None, + promotion_code: Optional[str] = None, + version: Optional[str] = None, + **kwargs + ): + """ + :keyword name: The plan name. + :paramtype name: str + :keyword publisher: The publisher ID. + :paramtype publisher: str + :keyword product: The product code. + :paramtype product: str + :keyword promotion_code: The promotion code. + :paramtype promotion_code: str + :keyword version: The plan's version. + :paramtype version: str + """ + super(PlanPatchable, self).__init__(**kwargs) + self.name = name + self.publisher = publisher + self.product = product + self.promotion_code = promotion_code + self.version = version + + +class Sku(msrest.serialization.Model): + """SKU for the resource. + + All required parameters must be populated in order to send to Azure. + + :ivar name: Required. The SKU name. + :vartype name: str + :ivar tier: The SKU tier. + :vartype tier: str + :ivar size: The SKU size. + :vartype size: str + :ivar family: The SKU family. + :vartype family: str + :ivar model: The SKU model. + :vartype model: str + :ivar capacity: The SKU capacity. + :vartype capacity: int + """ + + _validation = { + 'name': {'required': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'tier': {'key': 'tier', 'type': 'str'}, + 'size': {'key': 'size', 'type': 'str'}, + 'family': {'key': 'family', 'type': 'str'}, + 'model': {'key': 'model', 'type': 'str'}, + 'capacity': {'key': 'capacity', 'type': 'int'}, + } + + def __init__( + self, + *, + name: str, + tier: Optional[str] = None, + size: Optional[str] = None, + family: Optional[str] = None, + model: Optional[str] = None, + capacity: Optional[int] = None, + **kwargs + ): + """ + :keyword name: Required. The SKU name. + :paramtype name: str + :keyword tier: The SKU tier. + :paramtype tier: str + :keyword size: The SKU size. + :paramtype size: str + :keyword family: The SKU family. + :paramtype family: str + :keyword model: The SKU model. + :paramtype model: str + :keyword capacity: The SKU capacity. + :paramtype capacity: int + """ + super(Sku, self).__init__(**kwargs) + self.name = name + self.tier = tier + self.size = size + self.family = family + self.model = model + self.capacity = capacity + + +class SystemData(msrest.serialization.Model): + """Metadata pertaining to creation and last modification of the resource. + + :ivar created_by: The identity that created the resource. + :vartype created_by: str + :ivar created_by_type: The type of identity that created the resource. Known values are: + "User", "Application", "ManagedIdentity", "Key". + :vartype created_by_type: str or + ~azure.mgmt.managedapplication.v2021_07_01.models.CreatedByType + :ivar created_at: The timestamp of resource creation (UTC). + :vartype created_at: ~datetime.datetime + :ivar last_modified_by: The identity that last modified the resource. + :vartype last_modified_by: str + :ivar last_modified_by_type: The type of identity that last modified the resource. Known values + are: "User", "Application", "ManagedIdentity", "Key". + :vartype last_modified_by_type: str or + ~azure.mgmt.managedapplication.v2021_07_01.models.CreatedByType + :ivar last_modified_at: The timestamp of resource last modification (UTC). + :vartype last_modified_at: ~datetime.datetime + """ + + _attribute_map = { + 'created_by': {'key': 'createdBy', 'type': 'str'}, + 'created_by_type': {'key': 'createdByType', 'type': 'str'}, + 'created_at': {'key': 'createdAt', 'type': 'iso-8601'}, + 'last_modified_by': {'key': 'lastModifiedBy', 'type': 'str'}, + 'last_modified_by_type': {'key': 'lastModifiedByType', 'type': 'str'}, + 'last_modified_at': {'key': 'lastModifiedAt', 'type': 'iso-8601'}, + } + + def __init__( + self, + *, + created_by: Optional[str] = None, + created_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, + created_at: Optional[datetime.datetime] = None, + last_modified_by: Optional[str] = None, + last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, + last_modified_at: Optional[datetime.datetime] = None, + **kwargs + ): + """ + :keyword created_by: The identity that created the resource. + :paramtype created_by: str + :keyword created_by_type: The type of identity that created the resource. Known values are: + "User", "Application", "ManagedIdentity", "Key". + :paramtype created_by_type: str or + ~azure.mgmt.managedapplication.v2021_07_01.models.CreatedByType + :keyword created_at: The timestamp of resource creation (UTC). + :paramtype created_at: ~datetime.datetime + :keyword last_modified_by: The identity that last modified the resource. + :paramtype last_modified_by: str + :keyword last_modified_by_type: The type of identity that last modified the resource. Known + values are: "User", "Application", "ManagedIdentity", "Key". + :paramtype last_modified_by_type: str or + ~azure.mgmt.managedapplication.v2021_07_01.models.CreatedByType + :keyword last_modified_at: The timestamp of resource last modification (UTC). + :paramtype last_modified_at: ~datetime.datetime + """ + super(SystemData, self).__init__(**kwargs) + self.created_by = created_by + self.created_by_type = created_by_type + self.created_at = created_at + self.last_modified_by = last_modified_by + self.last_modified_by_type = last_modified_by_type + self.last_modified_at = last_modified_at + + +class UpdateAccessDefinition(msrest.serialization.Model): + """Update access request definition. + + All required parameters must be populated in order to send to Azure. + + :ivar approver: The approver name. + :vartype approver: str + :ivar metadata: Required. The JIT request metadata. + :vartype metadata: ~azure.mgmt.managedapplication.v2021_07_01.models.JitRequestMetadata + :ivar status: Required. The JIT status. Known values are: "NotSpecified", "Elevate", "Remove". + :vartype status: str or ~azure.mgmt.managedapplication.v2021_07_01.models.Status + :ivar sub_status: Required. The JIT status. Known values are: "NotSpecified", "Approved", + "Denied", "Failed", "Expired", "Timeout". + :vartype sub_status: str or ~azure.mgmt.managedapplication.v2021_07_01.models.Substatus + """ + + _validation = { + 'metadata': {'required': True}, + 'status': {'required': True}, + 'sub_status': {'required': True}, + } + + _attribute_map = { + 'approver': {'key': 'approver', 'type': 'str'}, + 'metadata': {'key': 'metadata', 'type': 'JitRequestMetadata'}, + 'status': {'key': 'status', 'type': 'str'}, + 'sub_status': {'key': 'subStatus', 'type': 'str'}, + } + + def __init__( + self, + *, + metadata: "_models.JitRequestMetadata", + status: Union[str, "_models.Status"], + sub_status: Union[str, "_models.Substatus"], + approver: Optional[str] = None, + **kwargs + ): + """ + :keyword approver: The approver name. + :paramtype approver: str + :keyword metadata: Required. The JIT request metadata. + :paramtype metadata: ~azure.mgmt.managedapplication.v2021_07_01.models.JitRequestMetadata + :keyword status: Required. The JIT status. Known values are: "NotSpecified", "Elevate", + "Remove". + :paramtype status: str or ~azure.mgmt.managedapplication.v2021_07_01.models.Status + :keyword sub_status: Required. The JIT status. Known values are: "NotSpecified", "Approved", + "Denied", "Failed", "Expired", "Timeout". + :paramtype sub_status: str or ~azure.mgmt.managedapplication.v2021_07_01.models.Substatus + """ + super(UpdateAccessDefinition, self).__init__(**kwargs) + self.approver = approver + self.metadata = metadata + self.status = status + self.sub_status = sub_status + + +class UserAssignedResourceIdentity(msrest.serialization.Model): + """Represents the user assigned identity that is contained within the UserAssignedIdentities dictionary on ResourceIdentity. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar principal_id: The principal id of user assigned identity. + :vartype principal_id: str + :ivar tenant_id: The tenant id of user assigned identity. + :vartype tenant_id: str + """ + + _validation = { + 'principal_id': {'readonly': True}, + 'tenant_id': {'readonly': True}, + } + + _attribute_map = { + 'principal_id': {'key': 'principalId', 'type': 'str'}, + 'tenant_id': {'key': 'tenantId', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(UserAssignedResourceIdentity, self).__init__(**kwargs) + self.principal_id = None + self.tenant_id = None diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_07_01/models/_patch.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_07_01/models/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_07_01/models/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_07_01/operations/__init__.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_07_01/operations/__init__.py new file mode 100644 index 000000000000..b93ecbbe65e2 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_07_01/operations/__init__.py @@ -0,0 +1,24 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._application_client_operations import ApplicationClientOperationsMixin +from ._applications_operations import ApplicationsOperations +from ._application_definitions_operations import ApplicationDefinitionsOperations +from ._jit_requests_operations import JitRequestsOperations + +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk +__all__ = [ + 'ApplicationClientOperationsMixin', + 'ApplicationsOperations', + 'ApplicationDefinitionsOperations', + 'JitRequestsOperations', +] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_07_01/operations/_application_client_operations.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_07_01/operations/_application_client_operations.py new file mode 100644 index 000000000000..602d6518ef09 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_07_01/operations/_application_client_operations.py @@ -0,0 +1,134 @@ +# 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.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._vendor import MixinABC, _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_operations_request( + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.Solutions/operations") + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + +class ApplicationClientOperationsMixin(MixinABC): + + @distributed_trace + def list_operations( + self, + **kwargs: Any + ) -> Iterable[_models.OperationListResult]: + """Lists all of the available Microsoft.Solutions REST API operations. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either OperationListResult or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.managedapplication.v2021_07_01.models.OperationListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # 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', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_operations_request( + api_version=api_version, + template_url=self.list_operations.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_operations_request( + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list_operations.metadata = {'url': "/providers/Microsoft.Solutions/operations"} # type: ignore diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_07_01/operations/_application_definitions_operations.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_07_01/operations/_application_definitions_operations.py new file mode 100644 index 000000000000..edcff89e7ccc --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_07_01/operations/_application_definitions_operations.py @@ -0,0 +1,1158 @@ +# 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.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._vendor import MixinABC, _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_request( + subscription_id: str, + resource_group_name: str, + application_definition_name: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}") # 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), + "applicationDefinitionName": _SERIALIZER.url("application_definition_name", application_definition_name, 'str', max_length=64, min_length=3), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_delete_request( + subscription_id: str, + resource_group_name: str, + application_definition_name: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}") # 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), + "applicationDefinitionName": _SERIALIZER.url("application_definition_name", application_definition_name, 'str', max_length=64, min_length=3), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_create_or_update_request( + subscription_id: str, + resource_group_name: str, + application_definition_name: str, + *, + json: Optional[_models.ApplicationDefinition] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}") # 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), + "applicationDefinitionName": _SERIALIZER.url("application_definition_name", application_definition_name, 'str', max_length=64, min_length=3), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_update_request( + subscription_id: str, + resource_group_name: str, + application_definition_name: str, + *, + json: Optional[_models.ApplicationDefinitionPatchable] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}") # 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), + "applicationDefinitionName": _SERIALIZER.url("application_definition_name", application_definition_name, 'str', max_length=64, min_length=3), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_list_by_resource_group_request( + subscription_id: str, + resource_group_name: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions") # 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 + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_list_by_subscription_request( + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Solutions/applicationDefinitions") + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_get_by_id_request( + resource_group_name: str, + application_definition_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "applicationDefinitionName": _SERIALIZER.url("application_definition_name", application_definition_name, 'str', max_length=64, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_delete_by_id_request( + resource_group_name: str, + application_definition_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "applicationDefinitionName": _SERIALIZER.url("application_definition_name", application_definition_name, 'str', max_length=64, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_create_or_update_by_id_request( + resource_group_name: str, + application_definition_name: str, + subscription_id: str, + *, + json: Optional[_models.ApplicationDefinition] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "applicationDefinitionName": _SERIALIZER.url("application_definition_name", application_definition_name, 'str', max_length=64, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_update_by_id_request( + subscription_id: str, + resource_group_name: str, + application_definition_name: str, + *, + json: Optional[_models.ApplicationDefinitionPatchable] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}") # 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), + "applicationDefinitionName": _SERIALIZER.url("application_definition_name", application_definition_name, 'str', max_length=64, min_length=3), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + +class ApplicationDefinitionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.managedapplication.v2021_07_01.ApplicationClient`'s + :attr:`application_definitions` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + + @distributed_trace + def get( + self, + resource_group_name: str, + application_definition_name: str, + **kwargs: Any + ) -> Optional[_models.ApplicationDefinition]: + """Gets the managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. + :type application_definition_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ApplicationDefinition, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2021_07_01.models.ApplicationDefinition or None + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.ApplicationDefinition]] + + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('ApplicationDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore + + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + application_definition_name: str, + **kwargs: Any + ) -> None: + """Deletes the managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. + :type application_definition_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + api_version=api_version, + template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore + + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + application_definition_name: str, + parameters: _models.ApplicationDefinition, + **kwargs: Any + ) -> _models.ApplicationDefinition: + """Creates or updates a managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. + :type application_definition_name: str + :param parameters: Parameters supplied to the create or update an managed application + definition. + :type parameters: ~azure.mgmt.managedapplication.v2021_07_01.models.ApplicationDefinition + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ApplicationDefinition, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2021_07_01.models.ApplicationDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationDefinition] + + _json = self._serialize.body(parameters, 'ApplicationDefinition') + + request = build_create_or_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # 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, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('ApplicationDefinition', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('ApplicationDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore + + + @distributed_trace + def update( + self, + resource_group_name: str, + application_definition_name: str, + parameters: _models.ApplicationDefinitionPatchable, + **kwargs: Any + ) -> _models.ApplicationDefinition: + """Updates the managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. + :type application_definition_name: str + :param parameters: Parameters supplied to the update a managed application definition. + :type parameters: + ~azure.mgmt.managedapplication.v2021_07_01.models.ApplicationDefinitionPatchable + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ApplicationDefinition, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2021_07_01.models.ApplicationDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationDefinition] + + _json = self._serialize.body(parameters, 'ApplicationDefinitionPatchable') + + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ApplicationDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore + + + @distributed_trace + def list_by_resource_group( + self, + resource_group_name: str, + **kwargs: Any + ) -> Iterable[_models.ApplicationDefinitionListResult]: + """Lists the managed application definitions in a resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ApplicationDefinitionListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.managedapplication.v2021_07_01.models.ApplicationDefinitionListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationDefinitionListResult] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + api_version=api_version, + template_url=self.list_by_resource_group.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ApplicationDefinitionListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions"} # type: ignore + + @distributed_trace + def list_by_subscription( + self, + **kwargs: Any + ) -> Iterable[_models.ApplicationDefinitionListResult]: + """Lists all the application definitions within a subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ApplicationDefinitionListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.managedapplication.v2021_07_01.models.ApplicationDefinitionListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationDefinitionListResult] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ApplicationDefinitionListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Solutions/applicationDefinitions"} # type: ignore + + @distributed_trace + def get_by_id( + self, + resource_group_name: str, + application_definition_name: str, + **kwargs: Any + ) -> Optional[_models.ApplicationDefinition]: + """Gets the managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. + :type application_definition_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ApplicationDefinition, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2021_07_01.models.ApplicationDefinition or None + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.ApplicationDefinition]] + + + request = build_get_by_id_request( + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_by_id.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('ApplicationDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_by_id.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore + + + @distributed_trace + def delete_by_id( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + application_definition_name: str, + **kwargs: Any + ) -> None: + """Deletes the managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. + :type application_definition_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_by_id_request( + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete_by_id.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete_by_id.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore + + + @distributed_trace + def create_or_update_by_id( + self, + resource_group_name: str, + application_definition_name: str, + parameters: _models.ApplicationDefinition, + **kwargs: Any + ) -> _models.ApplicationDefinition: + """Creates or updates a managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. + :type application_definition_name: str + :param parameters: Parameters supplied to the create or update a managed application + definition. + :type parameters: ~azure.mgmt.managedapplication.v2021_07_01.models.ApplicationDefinition + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ApplicationDefinition, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2021_07_01.models.ApplicationDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationDefinition] + + _json = self._serialize.body(parameters, 'ApplicationDefinition') + + request = build_create_or_update_by_id_request( + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + 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'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # 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, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('ApplicationDefinition', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('ApplicationDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_or_update_by_id.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore + + + @distributed_trace + def update_by_id( + self, + resource_group_name: str, + application_definition_name: str, + parameters: _models.ApplicationDefinitionPatchable, + **kwargs: Any + ) -> _models.ApplicationDefinition: + """Updates the managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. + :type application_definition_name: str + :param parameters: Parameters supplied to the update a managed application definition. + :type parameters: + ~azure.mgmt.managedapplication.v2021_07_01.models.ApplicationDefinitionPatchable + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ApplicationDefinition, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2021_07_01.models.ApplicationDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationDefinition] + + _json = self._serialize.body(parameters, 'ApplicationDefinitionPatchable') + + request = build_update_by_id_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.update_by_id.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ApplicationDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + update_by_id.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore + diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_07_01/operations/_applications_operations.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_07_01/operations/_applications_operations.py new file mode 100644 index 000000000000..a7f4d2addf3a --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_07_01/operations/_applications_operations.py @@ -0,0 +1,2090 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast + +from msrest import Serializer + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from .._vendor import MixinABC, _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_request( + subscription_id: str, + resource_group_name: str, + application_name: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}") # 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), + "applicationName": _SERIALIZER.url("application_name", application_name, 'str', max_length=64, min_length=3), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_delete_request_initial( + subscription_id: str, + resource_group_name: str, + application_name: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}") # 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), + "applicationName": _SERIALIZER.url("application_name", application_name, 'str', max_length=64, min_length=3), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_create_or_update_request_initial( + subscription_id: str, + resource_group_name: str, + application_name: str, + *, + json: Optional[_models.Application] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}") # 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), + "applicationName": _SERIALIZER.url("application_name", application_name, 'str', max_length=64, min_length=3), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_update_request_initial( + subscription_id: str, + resource_group_name: str, + application_name: str, + *, + json: Optional[_models.ApplicationPatchable] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}") # 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), + "applicationName": _SERIALIZER.url("application_name", application_name, 'str', max_length=64, min_length=3), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_list_by_resource_group_request( + subscription_id: str, + resource_group_name: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications") # 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 + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_list_by_subscription_request( + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Solutions/applications") + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_get_by_id_request( + application_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/{applicationId}") + path_format_arguments = { + "applicationId": _SERIALIZER.url("application_id", application_id, 'str', skip_quote=True), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_delete_by_id_request_initial( + application_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/{applicationId}") + path_format_arguments = { + "applicationId": _SERIALIZER.url("application_id", application_id, 'str', skip_quote=True), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_create_or_update_by_id_request_initial( + application_id: str, + *, + json: Optional[_models.Application] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/{applicationId}") + path_format_arguments = { + "applicationId": _SERIALIZER.url("application_id", application_id, 'str', skip_quote=True), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_update_by_id_request_initial( + application_id: str, + *, + json: Optional[_models.ApplicationPatchable] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/{applicationId}") + path_format_arguments = { + "applicationId": _SERIALIZER.url("application_id", application_id, 'str', skip_quote=True), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_refresh_permissions_request_initial( + subscription_id: str, + resource_group_name: str, + application_name: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}/refreshPermissions") # 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), + "applicationName": _SERIALIZER.url("application_name", application_name, 'str', max_length=64, min_length=3), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_list_allowed_upgrade_plans_request( + subscription_id: str, + resource_group_name: str, + application_name: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}/listAllowedUpgradePlans") # 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), + "applicationName": _SERIALIZER.url("application_name", application_name, 'str', max_length=64, min_length=3), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_update_access_request_initial( + subscription_id: str, + resource_group_name: str, + application_name: str, + *, + json: Optional[_models.UpdateAccessDefinition] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}/updateAccess") # 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), + "applicationName": _SERIALIZER.url("application_name", application_name, 'str', max_length=64, min_length=3), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_list_tokens_request( + subscription_id: str, + resource_group_name: str, + application_name: str, + *, + json: Optional[_models.ListTokenRequest] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}/listTokens") # 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), + "applicationName": _SERIALIZER.url("application_name", application_name, 'str', max_length=64, min_length=3), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + +class ApplicationsOperations: # pylint: disable=too-many-public-methods + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.managedapplication.v2021_07_01.ApplicationClient`'s + :attr:`applications` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + + @distributed_trace + def get( + self, + resource_group_name: str, + application_name: str, + **kwargs: Any + ) -> Optional[_models.Application]: + """Gets the managed application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_name: The name of the managed application. + :type application_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Application, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2021_07_01.models.Application or None + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.Application]] + + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + application_name=application_name, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('Application', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}"} # type: ignore + + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + application_name: str, + **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + application_name=application_name, + api_version=api_version, + template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}"} # type: ignore + + + @distributed_trace + def begin_delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + application_name: str, + **kwargs: Any + ) -> LROPoller[None]: + """Deletes the managed application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_name: The name of the managed application. + :type application_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._delete_initial( # type: ignore + resource_group_name=resource_group_name, + application_name=application_name, + api_version=api_version, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}"} # type: ignore + + def _create_or_update_initial( + self, + resource_group_name: str, + application_name: str, + parameters: _models.Application, + **kwargs: Any + ) -> _models.Application: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Application] + + _json = self._serialize.body(parameters, 'Application') + + request = build_create_or_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + application_name=application_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('Application', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('Application', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}"} # type: ignore + + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + application_name: str, + parameters: _models.Application, + **kwargs: Any + ) -> LROPoller[_models.Application]: + """Creates or updates a managed application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_name: The name of the managed application. + :type application_name: str + :param parameters: Parameters supplied to the create or update a managed application. + :type parameters: ~azure.mgmt.managedapplication.v2021_07_01.models.Application + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Application or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.managedapplication.v2021_07_01.models.Application] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Application] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._create_or_update_initial( # type: ignore + resource_group_name=resource_group_name, + application_name=application_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('Application', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}"} # type: ignore + + def _update_initial( + self, + resource_group_name: str, + application_name: str, + parameters: Optional[_models.ApplicationPatchable] = None, + **kwargs: Any + ) -> _models.ApplicationPatchable: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationPatchable] + + if parameters is not None: + _json = self._serialize.body(parameters, 'ApplicationPatchable') + else: + _json = None + + request = build_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + application_name=application_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('ApplicationPatchable', pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize('ApplicationPatchable', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}"} # type: ignore + + + @distributed_trace + def begin_update( + self, + resource_group_name: str, + application_name: str, + parameters: Optional[_models.ApplicationPatchable] = None, + **kwargs: Any + ) -> LROPoller[_models.ApplicationPatchable]: + """Updates an existing managed application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_name: The name of the managed application. + :type application_name: str + :param parameters: Parameters supplied to update an existing managed application. Default value + is None. + :type parameters: ~azure.mgmt.managedapplication.v2021_07_01.models.ApplicationPatchable + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ApplicationPatchable or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.managedapplication.v2021_07_01.models.ApplicationPatchable] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationPatchable] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._update_initial( # type: ignore + resource_group_name=resource_group_name, + application_name=application_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('ApplicationPatchable', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}"} # type: ignore + + @distributed_trace + def list_by_resource_group( + self, + resource_group_name: str, + **kwargs: Any + ) -> Iterable[_models.ApplicationListResult]: + """Lists all the applications within a resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ApplicationListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.managedapplication.v2021_07_01.models.ApplicationListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationListResult] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + api_version=api_version, + template_url=self.list_by_resource_group.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ApplicationListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications"} # type: ignore + + @distributed_trace + def list_by_subscription( + self, + **kwargs: Any + ) -> Iterable[_models.ApplicationListResult]: + """Lists all the applications within a subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ApplicationListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.managedapplication.v2021_07_01.models.ApplicationListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationListResult] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ApplicationListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Solutions/applications"} # type: ignore + + @distributed_trace + def get_by_id( + self, + application_id: str, + **kwargs: Any + ) -> Optional[_models.Application]: + """Gets the managed application. + + :param application_id: The fully qualified ID of the managed application, including the managed + application name and the managed application resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/Microsoft.Solutions/applications/{application-name}. + :type application_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Application, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2021_07_01.models.Application or None + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.Application]] + + + request = build_get_by_id_request( + application_id=application_id, + api_version=api_version, + template_url=self.get_by_id.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('Application', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_by_id.metadata = {'url': "/{applicationId}"} # type: ignore + + + def _delete_by_id_initial( # pylint: disable=inconsistent-return-statements + self, + application_id: str, + **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_by_id_request_initial( + application_id=application_id, + api_version=api_version, + template_url=self._delete_by_id_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_by_id_initial.metadata = {'url': "/{applicationId}"} # type: ignore + + + @distributed_trace + def begin_delete_by_id( # pylint: disable=inconsistent-return-statements + self, + application_id: str, + **kwargs: Any + ) -> LROPoller[None]: + """Deletes the managed application. + + :param application_id: The fully qualified ID of the managed application, including the managed + application name and the managed application resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/Microsoft.Solutions/applications/{application-name}. + :type application_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._delete_by_id_initial( # type: ignore + application_id=application_id, + api_version=api_version, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete_by_id.metadata = {'url': "/{applicationId}"} # type: ignore + + def _create_or_update_by_id_initial( + self, + application_id: str, + parameters: _models.Application, + **kwargs: Any + ) -> _models.Application: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Application] + + _json = self._serialize.body(parameters, 'Application') + + request = build_create_or_update_by_id_request_initial( + application_id=application_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._create_or_update_by_id_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('Application', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('Application', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_by_id_initial.metadata = {'url': "/{applicationId}"} # type: ignore + + + @distributed_trace + def begin_create_or_update_by_id( + self, + application_id: str, + parameters: _models.Application, + **kwargs: Any + ) -> LROPoller[_models.Application]: + """Creates or updates a managed application. + + :param application_id: The fully qualified ID of the managed application, including the managed + application name and the managed application resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/Microsoft.Solutions/applications/{application-name}. + :type application_id: str + :param parameters: Parameters supplied to the create or update a managed application. + :type parameters: ~azure.mgmt.managedapplication.v2021_07_01.models.Application + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Application or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.managedapplication.v2021_07_01.models.Application] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Application] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._create_or_update_by_id_initial( # type: ignore + application_id=application_id, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('Application', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update_by_id.metadata = {'url': "/{applicationId}"} # type: ignore + + def _update_by_id_initial( + self, + application_id: str, + parameters: Optional[_models.ApplicationPatchable] = None, + **kwargs: Any + ) -> _models.ApplicationPatchable: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationPatchable] + + if parameters is not None: + _json = self._serialize.body(parameters, 'ApplicationPatchable') + else: + _json = None + + request = build_update_by_id_request_initial( + application_id=application_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._update_by_id_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('ApplicationPatchable', pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize('ApplicationPatchable', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _update_by_id_initial.metadata = {'url': "/{applicationId}"} # type: ignore + + + @distributed_trace + def begin_update_by_id( + self, + application_id: str, + parameters: Optional[_models.ApplicationPatchable] = None, + **kwargs: Any + ) -> LROPoller[_models.ApplicationPatchable]: + """Updates an existing managed application. + + :param application_id: The fully qualified ID of the managed application, including the managed + application name and the managed application resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/Microsoft.Solutions/applications/{application-name}. + :type application_id: str + :param parameters: Parameters supplied to update an existing managed application. Default value + is None. + :type parameters: ~azure.mgmt.managedapplication.v2021_07_01.models.ApplicationPatchable + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ApplicationPatchable or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.managedapplication.v2021_07_01.models.ApplicationPatchable] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationPatchable] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._update_by_id_initial( # type: ignore + application_id=application_id, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('ApplicationPatchable', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_update_by_id.metadata = {'url': "/{applicationId}"} # type: ignore + + def _refresh_permissions_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + application_name: str, + **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_refresh_permissions_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + application_name=application_name, + api_version=api_version, + template_url=self._refresh_permissions_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _refresh_permissions_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}/refreshPermissions"} # type: ignore + + + @distributed_trace + def begin_refresh_permissions( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + application_name: str, + **kwargs: Any + ) -> LROPoller[None]: + """Refresh Permissions for application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_name: The name of the managed application. + :type application_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._refresh_permissions_initial( # type: ignore + resource_group_name=resource_group_name, + application_name=application_name, + api_version=api_version, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'location'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_refresh_permissions.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}/refreshPermissions"} # type: ignore + + @distributed_trace + def list_allowed_upgrade_plans( + self, + resource_group_name: str, + application_name: str, + **kwargs: Any + ) -> _models.AllowedUpgradePlansResult: + """List allowed upgrade plans for application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_name: The name of the managed application. + :type application_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AllowedUpgradePlansResult, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2021_07_01.models.AllowedUpgradePlansResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AllowedUpgradePlansResult] + + + request = build_list_allowed_upgrade_plans_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + application_name=application_name, + api_version=api_version, + template_url=self.list_allowed_upgrade_plans.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('AllowedUpgradePlansResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_allowed_upgrade_plans.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}/listAllowedUpgradePlans"} # type: ignore + + + def _update_access_initial( + self, + resource_group_name: str, + application_name: str, + parameters: _models.UpdateAccessDefinition, + **kwargs: Any + ) -> Optional[_models.UpdateAccessDefinition]: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.UpdateAccessDefinition]] + + _json = self._serialize.body(parameters, 'UpdateAccessDefinition') + + request = build_update_access_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + application_name=application_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._update_access_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 202: + deserialized = self._deserialize('UpdateAccessDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _update_access_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}/updateAccess"} # type: ignore + + + @distributed_trace + def begin_update_access( + self, + resource_group_name: str, + application_name: str, + parameters: _models.UpdateAccessDefinition, + **kwargs: Any + ) -> LROPoller[_models.UpdateAccessDefinition]: + """Update access for application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_name: The name of the managed application. + :type application_name: str + :param parameters: Request body parameters to list tokens. + :type parameters: ~azure.mgmt.managedapplication.v2021_07_01.models.UpdateAccessDefinition + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either UpdateAccessDefinition or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.managedapplication.v2021_07_01.models.UpdateAccessDefinition] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.UpdateAccessDefinition] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._update_access_initial( # type: ignore + resource_group_name=resource_group_name, + application_name=application_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('UpdateAccessDefinition', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'location'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_update_access.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}/updateAccess"} # type: ignore + + @distributed_trace + def list_tokens( + self, + resource_group_name: str, + application_name: str, + parameters: _models.ListTokenRequest, + **kwargs: Any + ) -> _models.ManagedIdentityTokenResult: + """List tokens for application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_name: The name of the managed application. + :type application_name: str + :param parameters: Request body parameters to list tokens. + :type parameters: ~azure.mgmt.managedapplication.v2021_07_01.models.ListTokenRequest + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ManagedIdentityTokenResult, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2021_07_01.models.ManagedIdentityTokenResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ManagedIdentityTokenResult] + + _json = self._serialize.body(parameters, 'ListTokenRequest') + + request = build_list_tokens_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + application_name=application_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.list_tokens.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ManagedIdentityTokenResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_tokens.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}/listTokens"} # type: ignore + diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_07_01/operations/_jit_requests_operations.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_07_01/operations/_jit_requests_operations.py new file mode 100644 index 000000000000..98ae836e6981 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_07_01/operations/_jit_requests_operations.py @@ -0,0 +1,736 @@ +# 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, Union, cast + +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.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from .._vendor import MixinABC, _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_request( + subscription_id: str, + resource_group_name: str, + jit_request_name: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/jitRequests/{jitRequestName}") # 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), + "jitRequestName": _SERIALIZER.url("jit_request_name", jit_request_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_create_or_update_request_initial( + subscription_id: str, + resource_group_name: str, + jit_request_name: str, + *, + json: Optional[_models.JitRequestDefinition] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/jitRequests/{jitRequestName}") # 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), + "jitRequestName": _SERIALIZER.url("jit_request_name", jit_request_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_update_request( + subscription_id: str, + resource_group_name: str, + jit_request_name: str, + *, + json: Optional[_models.JitRequestPatchable] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/jitRequests/{jitRequestName}") # 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), + "jitRequestName": _SERIALIZER.url("jit_request_name", jit_request_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request( + subscription_id: str, + resource_group_name: str, + jit_request_name: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/jitRequests/{jitRequestName}") # 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), + "jitRequestName": _SERIALIZER.url("jit_request_name", jit_request_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_list_by_subscription_request( + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Solutions/jitRequests") + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_list_by_resource_group_request( + subscription_id: str, + resource_group_name: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/jitRequests") # 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 + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + +class JitRequestsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.managedapplication.v2021_07_01.ApplicationClient`'s + :attr:`jit_requests` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + + @distributed_trace + def get( + self, + resource_group_name: str, + jit_request_name: str, + **kwargs: Any + ) -> Optional[_models.JitRequestDefinition]: + """Gets the JIT request. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param jit_request_name: The name of the JIT request. + :type jit_request_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JitRequestDefinition, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2021_07_01.models.JitRequestDefinition or None + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.JitRequestDefinition]] + + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + jit_request_name=jit_request_name, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('JitRequestDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/jitRequests/{jitRequestName}"} # type: ignore + + + def _create_or_update_initial( + self, + resource_group_name: str, + jit_request_name: str, + parameters: _models.JitRequestDefinition, + **kwargs: Any + ) -> _models.JitRequestDefinition: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.JitRequestDefinition] + + _json = self._serialize.body(parameters, 'JitRequestDefinition') + + request = build_create_or_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + jit_request_name=jit_request_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('JitRequestDefinition', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('JitRequestDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/jitRequests/{jitRequestName}"} # type: ignore + + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + jit_request_name: str, + parameters: _models.JitRequestDefinition, + **kwargs: Any + ) -> LROPoller[_models.JitRequestDefinition]: + """Creates or updates the JIT request. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param jit_request_name: The name of the JIT request. + :type jit_request_name: str + :param parameters: Parameters supplied to the update JIT request. + :type parameters: ~azure.mgmt.managedapplication.v2021_07_01.models.JitRequestDefinition + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either JitRequestDefinition or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.managedapplication.v2021_07_01.models.JitRequestDefinition] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.JitRequestDefinition] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._create_or_update_initial( # type: ignore + resource_group_name=resource_group_name, + jit_request_name=jit_request_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('JitRequestDefinition', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/jitRequests/{jitRequestName}"} # type: ignore + + @distributed_trace + def update( + self, + resource_group_name: str, + jit_request_name: str, + parameters: _models.JitRequestPatchable, + **kwargs: Any + ) -> _models.JitRequestDefinition: + """Updates the JIT request. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param jit_request_name: The name of the JIT request. + :type jit_request_name: str + :param parameters: Parameters supplied to the update JIT request. + :type parameters: ~azure.mgmt.managedapplication.v2021_07_01.models.JitRequestPatchable + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JitRequestDefinition, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2021_07_01.models.JitRequestDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.JitRequestDefinition] + + _json = self._serialize.body(parameters, 'JitRequestPatchable') + + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + jit_request_name=jit_request_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('JitRequestDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/jitRequests/{jitRequestName}"} # type: ignore + + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + jit_request_name: str, + **kwargs: Any + ) -> None: + """Deletes the JIT request. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param jit_request_name: The name of the JIT request. + :type jit_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 + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + jit_request_name=jit_request_name, + api_version=api_version, + template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/jitRequests/{jitRequestName}"} # type: ignore + + + @distributed_trace + def list_by_subscription( + self, + **kwargs: Any + ) -> _models.JitRequestDefinitionListResult: + """Lists all JIT requests within the subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JitRequestDefinitionListResult, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2021_07_01.models.JitRequestDefinitionListResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.JitRequestDefinitionListResult] + + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('JitRequestDefinitionListResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Solutions/jitRequests"} # type: ignore + + + @distributed_trace + def list_by_resource_group( + self, + resource_group_name: str, + **kwargs: Any + ) -> _models.JitRequestDefinitionListResult: + """Lists all JIT requests within the 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: JitRequestDefinitionListResult, or the result of cls(response) + :rtype: ~azure.mgmt.managedapplication.v2021_07_01.models.JitRequestDefinitionListResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.JitRequestDefinitionListResult] + + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + api_version=api_version, + template_url=self.list_by_resource_group.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('JitRequestDefinitionListResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/jitRequests"} # type: ignore + diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_07_01/operations/_patch.py b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_07_01/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_07_01/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_07_01/py.typed b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_07_01/py.typed new file mode 100644 index 000000000000..e5aff4f83af8 --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/azure/mgmt/managedapplication/v2021_07_01/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/sdk_packaging.toml b/sdk/managedapplication/azure-mgmt-managedapplication/sdk_packaging.toml new file mode 100644 index 000000000000..bb48be041e4c --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/sdk_packaging.toml @@ -0,0 +1,9 @@ +[packaging] +package_name = "azure-mgmt-managedapplication" +package_nspkg = "azure-mgmt-nspkg" +package_pprint_name = "MyService Management" +package_doc_id = "" +is_stable = false +is_arm = true +need_msrestazure = false +need_azuremgmtcore = true diff --git a/sdk/managedapplication/azure-mgmt-managedapplication/setup.py b/sdk/managedapplication/azure-mgmt-managedapplication/setup.py new file mode 100644 index 000000000000..ea332737e2cb --- /dev/null +++ b/sdk/managedapplication/azure-mgmt-managedapplication/setup.py @@ -0,0 +1,77 @@ +#!/usr/bin/env python + +#------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +#-------------------------------------------------------------------------- + +import re +import os.path +from io import open +from setuptools import find_packages, setup + +# Change the PACKAGE_NAME only to change folder and different name +PACKAGE_NAME = "azure-mgmt-managedapplication" +PACKAGE_PPRINT_NAME = "MyService Management" + +# a-b-c => a/b/c +package_folder_path = PACKAGE_NAME.replace('-', '/') +# a-b-c => a.b.c +namespace_name = PACKAGE_NAME.replace('-', '.') + +# Version extraction inspired from 'requests' +with open(os.path.join(package_folder_path, 'version.py') + if os.path.exists(os.path.join(package_folder_path, 'version.py')) + else os.path.join(package_folder_path, '_version.py'), 'r') as fd: + version = re.search(r'^VERSION\s*=\s*[\'"]([^\'"]*)[\'"]', + fd.read(), re.MULTILINE).group(1) + +if not version: + raise RuntimeError('Cannot find version information') + +with open('README.md', encoding='utf-8') as f: + readme = f.read() +with open('CHANGELOG.md', encoding='utf-8') as f: + changelog = f.read() + +setup( + name=PACKAGE_NAME, + version=version, + description='Microsoft Azure {} Client Library for Python'.format(PACKAGE_PPRINT_NAME), + long_description=readme + '\n\n' + changelog, + long_description_content_type='text/markdown', + license='MIT License', + author='Microsoft Corporation', + author_email='azpysdkhelp@microsoft.com', + url='https://github.com/Azure/azure-sdk-for-python', + keywords="azure, azure sdk", # update with search keywords relevant to the azure service / product + classifiers=[ + 'Development Status :: 4 - Beta', + 'Programming Language :: Python', + 'Programming Language :: Python :: 3 :: Only', + 'Programming Language :: Python :: 3', + 'Programming Language :: Python :: 3.7', + 'Programming Language :: Python :: 3.8', + 'Programming Language :: Python :: 3.9', + 'Programming Language :: Python :: 3.10', + 'License :: OSI Approved :: MIT License', + ], + zip_safe=False, + packages=find_packages(exclude=[ + 'tests', + # Exclude packages that will be covered by PEP420 or nspkg + 'azure', + 'azure.mgmt', + ]), + include_package_data=True, + package_data={ + 'pytyped': ['py.typed'], + }, + install_requires=[ + 'msrest>=0.6.21', + 'azure-common~=1.1', + 'azure-mgmt-core>=1.3.1,<2.0.0', + ], + python_requires=">=3.7" +) diff --git a/sdk/managedapplication/ci.yml b/sdk/managedapplication/ci.yml new file mode 100644 index 000000000000..1a4d99745f89 --- /dev/null +++ b/sdk/managedapplication/ci.yml @@ -0,0 +1,33 @@ +# DO NOT EDIT THIS FILE +# This file is generated automatically and any changes will be lost. + +trigger: + branches: + include: + - main + - hotfix/* + - release/* + - restapi* + paths: + include: + - sdk/managedapplication/ + +pr: + branches: + include: + - main + - feature/* + - hotfix/* + - release/* + - restapi* + paths: + include: + - sdk/managedapplication/ + +extends: + template: ../../eng/pipelines/templates/stages/archetype-sdk-client.yml + parameters: + ServiceDirectory: managedapplication + Artifacts: + - name: azure-mgmt-managedapplication + safeName: azuremgmtmanagedapplication